Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFRA] Improve GitHub workflow and remove duplications #567

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/build-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Build Setup'
description: 'Setup node and install dependencies'

runs:
using: 'composite'
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
install-command: npm ci --prefer-offline --audit false --legacy-peer-deps
9 changes: 2 additions & 7 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Build Setup
uses: ./.github/actions/build-setup
- name: Lint check
run: npm run lint-check
- name: Check types
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Build Setup
uses: ./.github/actions/build-setup
- name: create .env.production file
run: |
touch .env.production
Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/generate-site-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,25 @@ permissions:
pull-requests: write

jobs:
# inspired from https://github.com/process-analytics/github-actions-playground/pull/23
check_secrets:
runs-on: ubuntu-20.04
outputs:
is_SURGE_TOKEN_set: ${{ steps.secret_availability.outputs.is_SURGE_TOKEN_set }}
steps:
- name: Compute secrets availability
id: secret_availability
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
run: |
echo "is_SURGE_TOKEN_set: ${{ env.SURGE_TOKEN != '' }}"
echo "::set-output name=is_SURGE_TOKEN_set::${{ env.SURGE_TOKEN != '' }}"

site_preview:
needs: [check_secrets]
if: needs.check_secrets.outputs.is_SURGE_TOKEN_set == 'true'
runs-on: ubuntu-20.04
steps:
- uses: bonitasoft/actions/packages/surge-preview-tools@v1.2.0
id: surge-preview-tools
with:
surge-token: ${{ secrets.SURGE_TOKEN }}
- uses: actions/checkout@v3
if: github.event.action != 'closed'
- name: Build Setup
if: github.event.action != 'closed'
uses: ./.github/actions/build-setup
- name: create .env.production file
if: github.event.action != 'closed'
run: |
touch .env.production
echo GATSBY_GA_MEASUREMENT_ID =${{ secrets.TEST_GA_MEASUREMENT_ID }} >> .env.production
- name: Publish Site preview
id: publish_site_preview
if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
uses: afc163/surge-preview@v1
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
Expand All @@ -54,5 +45,4 @@ jobs:
failOnError: true
teardown: 'true'
build: |
npm ci --legacy-peer-deps
npm run build