Skip to content

Commit

Permalink
Reconfiguring GitHub actions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ajmeese7 committed Jun 6, 2022
1 parent 3410f07 commit f9f1827
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 0 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
11 changes: 7 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
11 changes: 5 additions & 6 deletions .github/workflows/pr-checker-secrets.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pr Checker with Secrets
name: PR Checker with Secrets

on:
pull_request:
Expand Down Expand Up @@ -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
Expand All @@ -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}}
12 changes: 11 additions & 1 deletion .github/workflows/pr-checker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pr Checker
name: PR Checker

on:
pull_request:
Expand All @@ -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}}
30 changes: 0 additions & 30 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion bin/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...");
Expand Down
8 changes: 4 additions & 4 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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,
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f9f1827

Please sign in to comment.