GitHub Actions

👋 FYI, this note is over 6 months old. Some of the content may be out of date.
On this page

Docs:

Example workflows Jump to heading

On push Jump to heading

name: learn-github-actions
on: [push]
jobs:
check-bats-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm install -g bats
- run: bats -v

PRs only Jump to heading

name: Run on PR
'on': pull_request
jobs:
build_and_preview:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn --prefer-offline
- name: bundlephobia-checker
# https://github.com/carlesnunez/check-my-bundlephobia
uses: carlesnunez/check-my-bundlephobia@v1.8.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
strict: true
threshold: 800
ignore-dev-dependencies: true
- name: Lint
run: yarn lint
- name: Test
run: yarn test
- name: Build app
run: yarn build

On merge into main branch Jump to heading

name: Run on merge
'on':
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn --prefer-offline
- name: Lint
run: yarn lint
- name: Test
run: yarn test
- name: Build app
run: yarn build
- name: Build Storybook
run: yarn storybook:build

Enable debug logging Jump to heading

Set either/both in your repo’s secrets:

  • ACTIONS_STEP_DEBUG=true
  • ACTIONS_RUNNER_DEBUG=true

← Back home