Skip to content

Pass env var through CI #372

Pass env var through CI

Pass env var through CI #372

Workflow file for this run

name: Build
on: [push, pull_request ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- name: Dump GitHub context
if: ${{ github.event.pull_request.base.ref == 'master' }}
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
BASE_REF: ${{ github.base_ref }}
MERGED: ${{ github.event.pull_request.merged }}
run: |
echo "$GITHUB_CONTEXT"
echo "$BASE_REF == 'master'"
echo "$MERGED == true"
echo "$MERGED == 'true'"
# Builds and caches the node_modules for future jobs
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node_modules
uses: actions/cache@v2
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
# Ensures that versions match on pull request to master to ensure we're not going to end up with mismatched versions (master)
prepare_publish:
needs: [ build ]
# if the target branch is master. We want to make sure we're not merging anything into master that's unpublishable
if: ${{ github.base_ref == 'master' && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore node_modules
uses: actions/cache@v2
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
- name: Prepare Publish script
run: yarn run prep-publish
env:
GCP_CLIENT_ID: ${{ secrets.GCP_CLIENT_ID }}
GCP_CLIENT_SECRET: ${{ secrets.GCP_CLIENT_SECRET }}
GCP_REFRESH_TOKEN: ${{ secrets.GCP_REFRESH_TOKEN }}
# Runs code coverage and pushes to third party which will update pull request if exists
code_coverage:
needs: [ build ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore node_modules
uses: actions/cache@v2
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
- name: Unit tests
run: yarn run test-all
# use hash for safety reasons, using master/tags can introduce security risks into workflow
- name: Push code coverage
uses: codecov/codecov-action@2838b54ec211d3f145409dbf867d4b3f22af4637
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true # optional (default = false)
verbose: false # optional (default = false)
# Builds the zip file artifact for debugging or for pushing to the web store
build_zip:
needs: [ code_coverage ]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Restore node_modules
uses: actions/cache@v2
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.os }}-yarn-v1-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v1-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
- name: Build extension
run: yarn run build-ext
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: extension
path: ./build
# Publishes to the web store
publish:
needs: [ build_zip, code_coverage ]
# if the target branch is master. We want to make sure we're not merging anything into master that's unpublishable
if: ${{ github.event.pull_request.base.ref == 'master' && github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 18.x ]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Publish to Chrome Webstore
run: yarn run publish
env:
GCP_CLIENT_ID: ${{ secrets.GCP_CLIENT_ID }}
GCP_REFRESH_TOKEN: ${{ secrets.GCP_REFRESH_TOKEN }}