From f9f1827997a5f74d6f7a5671c9d3c4e1d08298c8 Mon Sep 17 00:00:00 2001 From: Aaron Meese Date: Mon, 6 Jun 2022 19:25:26 -0400 Subject: [PATCH] Reconfiguring GitHub actions Deploying to Netlify works fine, but I'd rather have my code on GitHub Pages if possible. This is an effort to get that to work. --- .editorconfig | 4 ++++ .env.example | 5 ++-- .github/workflows/auto-merge.yml | 2 +- .github/workflows/codeql-analysis.yml | 1 - .github/workflows/master.yml | 11 +++++---- .github/workflows/pr-checker-secrets.yml | 11 ++++----- .github/workflows/pr-checker.yml | 12 +++++++++- .github/workflows/release.yml | 30 ------------------------ bin/setup.mjs | 2 +- gatsby-config.js | 8 +++---- gatsby-node.js | 4 ++-- package.json | 3 +-- 12 files changed, 39 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.editorconfig b/.editorconfig index 2265467..6ccd9f8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,7 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.env.example b/.env.example index 178c2cd..fba936a 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ -ACCESS_TOKEN=your_access_token_here -SPACE_ID=your_space_id_here +CONTENTFUL_ACCESS_TOKEN=your_contentful_access_token_here +CONTENTFUL_SPACE_ID=your_contentful_space_id_here +GITHUB_ACCESS_TOKEN=ghp_your_access_token_here diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index c50793c..b42561c 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -14,4 +14,4 @@ jobs: - uses: ahmadnassri/action-dependabot-auto-merge@v2 with: target: minor - github-token: ${{ secrets.ACCESS_TOKEN }} + github-token: ${{ secrets.GITHUB_ACCESS_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8e92927..28b3ff8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -64,7 +64,6 @@ jobs: #- run: | # make bootstrap - # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index dec115b..9be369a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -23,7 +23,10 @@ jobs: - run: yarn install --frozen-lockfile - - run: yarn build - env: - ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} - SPACE_ID: ${{secrets.SPACE_ID}} + - uses: enriikke/gatsby-gh-pages-action@v2 + with: + access-token: ${{ secrets.GITHUB_ACCESS_TOKEN }} + deploy-branch: gh-pages + gatsby-args: --prefix-paths + CONTENTFUL_ACCESS_TOKEN: ${{secrets.CONTENTFUL_ACCESS_TOKEN}} + CONTENTFUL_SPACE_ID: ${{secrets.CONTENTFUL_SPACE_ID}} diff --git a/.github/workflows/pr-checker-secrets.yml b/.github/workflows/pr-checker-secrets.yml index 391402c..fa51702 100644 --- a/.github/workflows/pr-checker-secrets.yml +++ b/.github/workflows/pr-checker-secrets.yml @@ -1,4 +1,4 @@ -name: Pr Checker with Secrets +name: PR Checker with Secrets on: pull_request: @@ -30,8 +30,8 @@ jobs: - run: yarn build env: - ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} - SPACE_ID: ${{secrets.SPACE_ID}} + CONTENTFUL_ACCESS_TOKEN: ${{secrets.CONTENTFUL_ACCESS_TOKEN}} + CONTENTFUL_SPACE_ID: ${{secrets.CONTENTFUL_SPACE_ID}} test: runs-on: ubuntu-latest @@ -54,6 +54,5 @@ jobs: - run: yarn test:ci env: - ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} - SPACE_ID: ${{secrets.SPACE_ID}} - PERCY_TOKEN: ${{secrets.PERCY_TOKEN}} + CONTENTFUL_ACCESS_TOKEN: ${{secrets.CONTENTFUL_ACCESS_TOKEN}} + CONTENTFUL_SPACE_ID: ${{secrets.CONTENTFUL_SPACE_ID}} diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml index 5f543d5..7d4d4ae 100644 --- a/.github/workflows/pr-checker.yml +++ b/.github/workflows/pr-checker.yml @@ -1,4 +1,4 @@ -name: Pr Checker +name: PR Checker on: pull_request: @@ -23,3 +23,13 @@ jobs: - run: yarn install --frozen-lockfile - run: yarn check-types + + - name: Dry run the deployment + uses: enriikke/gatsby-gh-pages-action@v2 + with: + access-token: ${{ secrets.GITHUB_ACCESS_TOKEN }} + deploy-branch: gh-pages + gatsby-args: --prefix-paths + skip-publish: true + CONTENTFUL_ACCESS_TOKEN: ${{secrets.CONTENTFUL_ACCESS_TOKEN}} + CONTENTFUL_SPACE_ID: ${{secrets.CONTENTFUL_SPACE_ID}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5e36024..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release - -on: - push: - branches: - - master - -jobs: - release: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Read .nvmrc - id: node_version - run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) - - - name: Setup node - uses: actions/setup-node@v1 - with: - node-version: ${{ steps.node_version.outputs.NODE_VERSION }} - - - run: yarn install --frozen-lockfile - - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: yarn release diff --git a/bin/setup.mjs b/bin/setup.mjs index b3f904b..3a6c6e4 100644 --- a/bin/setup.mjs +++ b/bin/setup.mjs @@ -47,7 +47,7 @@ const setup = async () => { ); console.log("Writing config file..."); - const envData = [`SPACE_ID=${spaceId}`, `ACCESS_TOKEN=${deliveryToken}`]; + const envData = [`CONTENTFUL_SPACE_ID=${spaceId}`, `CONTENTFUL_ACCESS_TOKEN=${deliveryToken}`]; writeFileSync(CONFIG_FILE_PATH, envData.join(os.EOL)); console.log("Importing content into your Contentful ..."); diff --git a/gatsby-config.js b/gatsby-config.js index b840468..a4f15cf 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,8 +1,8 @@ const assert = require("assert"); const colors = require("./src/colors.json"); -const { ACCESS_TOKEN, SPACE_ID, DETERMINISTIC } = process.env; -assert(ACCESS_TOKEN, "Contentful Access Token not provided"); +const { CONTENTFUL_ACCESS_TOKEN, CONTENTFUL_SPACE_ID, DETERMINISTIC } = process.env; +assert(CONTENTFUL_ACCESS_TOKEN, "Contentful Access Token not provided"); assert(SPACE_ID, "Contentful Space ID not provided"); module.exports = { @@ -31,8 +31,8 @@ module.exports = { { resolve: "gatsby-source-contentful", options: { - spaceId: SPACE_ID, - accessToken: ACCESS_TOKEN, + spaceId: CONTENTFUL_SPACE_ID, + accessToken: CONTENTFUL_ACCESS_TOKEN, }, }, ], diff --git a/gatsby-node.js b/gatsby-node.js index 65d69df..f91bee6 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -10,8 +10,8 @@ const ModalTemplate = require.resolve("./src/templates/Modal.tsx"); const NotFoundTemplate = require.resolve("./src/templates/NotFound.tsx"); exports.sourceNodes = async (gatsbyConfig) => { - const { ACCESS_TOKEN, SPACE_ID } = process.env; - const client = createClient({ space: SPACE_ID, accessToken: ACCESS_TOKEN }); + const { CONTENTFUL_ACCESS_TOKEN, CONTENTFUL_SPACE_ID } = process.env; + const client = createClient({ space: CONTENTFUL_SPACE_ID, accessToken: CONTENTFUL_ACCESS_TOKEN }); const { items } = await client.getEntries(); const companyInformation = items.find(getCompanyInformationEntry); diff --git a/package.json b/package.json index 8113d8c..ac8d193 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,7 @@ "serve": "env-cmd --silent gatsby serve -p 5000", "setup": "node ./bin/setup.mjs", "test:ci": "yarn build && start-server-and-test serve 5000", - "check-types": "tsc -p . --noEmit", - "release": "npx semantic-release" + "check-types": "tsc -p . --noEmit" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.36",