Merge pull request #42 from infinitered/workflow #34
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
name: Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Install Dependencies | |
run: yarn install --immutable | |
- name: Version Packages or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
version: yarn version | |
publish: yarn release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
continue-on-error: true | |
- name: Check if changeset was published | |
id: check-publish | |
run: | | |
if [[ -n "$(cat ./yarn-release.log | grep '${{ github.run_id }}')" ]]; then | |
echo "published=true" >> $GITHUB_OUTPUT | |
else | |
echo "published=false" >> $GITHUB_OUTPUT | |
fi | |
deploy_docs: | |
name: Deploy Docusaurus to GitHub Pages | |
runs-on: ubuntu-latest | |
needs: release # This job depends on the release job | |
if: needs.release.outputs.check-publish.published == 'true' # Check the output of the check-publish step | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: yarn | |
- run: yarn install --frozen-lockfile | |
- name: Build website | |
run: yarn build:docs | |
# Popular action to deploy to GitHub Pages: | |
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# Build output to publish to the `gh-pages` branch: | |
publish_dir: ./packages/docusaurus/build | |
# The following lines assign commit authorship to the official | |
# GH-Actions bot for deploys to `gh-pages` branch: | |
# https://github.com/actions/checkout/issues/13#issuecomment-724415212 | |
# The GH actions bot is used by default if you didn't specify the two fields. | |
# You can swap them out with your own user credentials. | |
user_name: github-actions[bot] | |
user_email: 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Cleanup old release log | |
run: | | |
rm -f ./yarn-release.log |