Skip to content

Commit

Permalink
Refactor GitHub workflows (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
dshevtsov authored Aug 20, 2024
1 parent 95d172a commit 3c2ea8b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 73 deletions.
21 changes: 7 additions & 14 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
---
name: Github Pages
on: workflow_dispatch
permissions: {}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node v16
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Build site
run: yarn build
env:
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,13 @@ jobs:
build-and-index:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node v16
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Build site
run: yarn build

Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,13 @@ jobs:
needs: [set-state, pre-build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node v16
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Gatsby Cache
uses: actions/cache@v3.3.2
with:
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,13 @@
needs: [set-state, pre-build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node v16
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Gatsby Cache
uses: actions/cache@v3.3.2
with:
Expand Down
45 changes: 28 additions & 17 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
# Start the job on a pull request to the main branch #
######################################################
on: pull_request

#################################################
# Disable all permissions on the workflow level #
#################################################
permissions: {}

###############
# Set the Job #
Expand All @@ -29,7 +34,6 @@
############################################
permissions:
contents: read
packages: read
statuses: write

##################
Expand All @@ -56,34 +60,41 @@
# Use full version number to avoid cases when a next
# released version is buggy
# About slim image: https://github.com/github/super-linter#slim-image
uses: super-linter/super-linter/slim@v6.7.0
uses: super-linter/super-linter/slim@v7.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
test_and_build:

test:
runs-on: ubuntu-latest
needs: lint
permissions:
contents: read
statuses: write
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Enable Corepack for Yarn
run: corepack enable

- name: Install Dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: Check links
run: yarn test

build:
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
statuses: write
steps:
- uses: actions/checkout@v4
- name: Use Setup Node and Install Dependencies Action
uses: commerce-docs/devsite-install-action@main
with:
node-version-file: '.nvmrc'
cache-dependency-path: 'yarn.lock'

- name: Build site
run: yarn build

0 comments on commit 3c2ea8b

Please sign in to comment.