Skip to content

Commit

Permalink
Run dependabot CI without GitHub secrets (#1204)
Browse files Browse the repository at this point in the history
Due to
https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/,
Dependabot PRs don't have access to GH secrets. In particular, that
means they can't run e2e tests, and can't deploy a preview app on NPM.
So far, we have manually re-run the dependabot PRs to get access to the
secrets. This commit makes it so that Dependabot PRs run without e2e
tests or NPM preview, so that a human user does not need to be involved.

To achieve that, any step of the workflow that requires a GH secret only gets executed if it isn't triggered by dependabot.
  • Loading branch information
NSeydoux authored Mar 25, 2021
1 parent dd70873 commit 69447c8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cd-preview.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: CD-preview

on:
push:
branches-ignore:
- dependabot/*
on: [push, workflow_dispatch]

env:
CI: true
jobs:
dev-release-npm:
name: "NPM release under a dev tag"
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
# Dependabot cannot access secrets, so it doesn't have a token to publish to NPM.
# Since all the other jobs of this workflow depend on this one, skipping it should
# skip the entire workflow.
if: ${{ github.actor != 'dependabot' }}
outputs:
version-nr: ${{ steps.determine-npm-version.outputs.version-nr }}
steps:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cd-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ env:
jobs:
unpublish-npm:
runs-on: ubuntu-20.04
if: github.event.ref_type == 'branch'
# Dependabot cannot access secrets, so it doesn't have a token to publish to NPM.
# Since all the other jobs of this workflow depend on this one, skipping it should
# skip the entire workflow.
if: ${{github.event.ref_type == 'branch' && github.actor != 'dependabot'}}
steps:
- name: Prepare for unpublication from npm
uses: actions/[email protected]
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
on: [push, workflow_dispatch]

env:
CI: true
Expand Down Expand Up @@ -29,7 +29,11 @@ jobs:
- run: npm run bootstrap -- --ci
- run: npm run build
- run: npm run test
- run: npm run e2e-test
- # Dependabot cannot access secrets, so it doesn't have a token to authenticate to ESS.
# Since all the other jobs of this workflow depend on this one, skipping it should
# skip the entire workflow.
if: ${{ github.actor != 'dependabot' }}
run: npm run e2e-test
env:
E2E_TEST_REFRESH_TOKEN: ${{ secrets.E2E_TEST_REFRESH_TOKEN }}
E2E_TEST_CLIENT_ID: ${{ secrets.E2E_TEST_CLIENT_ID }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e-browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
path: e2e/browser/node_modules
key: ${{ runner.os }}-node${{ runner.node-version }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Run tests
# Dependabot cannot access secrets, so it doesn't have a token to authenticate to ESS.
# Since all the other jobs of this workflow depend on this one, skipping it should
# skip the entire workflow.
if: ${{ github.actor != 'dependabot' }}
run: |
cd e2e/browser;
npm ci;
Expand Down

0 comments on commit 69447c8

Please sign in to comment.