Publish #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This workflow has access to secrets and a read-write token | |
name: Publish | |
on: | |
workflow_run: | |
branches: [master] | |
types: [completed] | |
workflows: [CI] | |
jobs: | |
# Why do we need to build here as well as in the main CI pipeline? Because the actions/download-artifact action | |
# doesn't allow you to download artifacts from other workflows, despite GitHub pushing that as the recommended | |
# work-around for Dependabot permissions. See: https://github.com/actions/download-artifact/issues/60 | |
build: | |
runs-on: ubuntu-latest | |
name: Build | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- 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@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- run: yarn install | |
- run: yarn build | |
- uses: actions/upload-artifact@v1 | |
with: | |
name: build | |
path: lib | |
publish: | |
runs-on: ubuntu-latest | |
name: Publish | |
needs: build | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v1 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- run: yarn install | |
- uses: actions/download-artifact@v1 | |
with: | |
name: build | |
path: lib | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- run: yarn semantic-release | |
env: | |
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
NPM_TOKEN: ${{secrets.NPM_TOKEN}} |