-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GitHub actions to latest from module template (#276)
* Update GitHub actions to latest from module template The GitHub actions have been updated to match the latest module template actions. The main difference is that the `require-additional- reviewer` action has been omitted because it's currently broken for forks. This adds support for npm publishing, and it improves how the documentation is published. We'll now have a separate subdirectory for the docs for each release, as well as directories for latest stable and staging. * Update actionlint Co-authored-by: Maarten Zuidhoorn <[email protected]> Co-authored-by: Maarten Zuidhoorn <[email protected]>
- Loading branch information
Showing
12 changed files
with
383 additions
and
121 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
name: Build, Lint, and Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
prepare: | ||
name: Prepare | ||
runs-on: ubuntu-latest | ||
outputs: | ||
YARN_CACHE_DIR: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} | ||
YARN_VERSION: ${{ steps.yarn-version.outputs.YARN_VERSION }} | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 19.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Get Yarn cache directory | ||
run: echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" | ||
id: yarn-cache-dir | ||
- name: Get Yarn version | ||
run: echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT" | ||
id: yarn-version | ||
- name: Cache Yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} | ||
- name: Install Yarn dependencies | ||
run: yarn --immutable | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 19.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Restore Yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} | ||
- run: yarn --immutable | ||
- run: yarn build | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 19.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Restore Yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} | ||
- run: yarn --immutable | ||
- run: yarn lint | ||
- name: Validate RC changelog | ||
if: ${{ startsWith(github.head_ref, 'release/') }} | ||
run: yarn auto-changelog validate --rc | ||
- name: Validate changelog | ||
if: ${{ !startsWith(github.head_ref, 'release/') }} | ||
run: yarn auto-changelog validate | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare | ||
strategy: | ||
matrix: | ||
node-version: [14.x, 16.x, 18.x, 19.x] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Restore Yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }} | ||
- run: yarn --immutable | ||
- run: yarn test | ||
- name: Require clean working directory | ||
shell: bash | ||
run: | | ||
if ! git diff --exit-code; then | ||
echo "Working tree dirty at end of job" | ||
exit 1 | ||
fi | ||
check-workflows: | ||
name: Check workflows | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Download actionlint | ||
id: download-actionlint | ||
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.22 | ||
shell: bash | ||
- name: Check workflow files | ||
run: ${{ steps.download-actionlint.outputs.executable }} -color | ||
shell: bash | ||
all-jobs-pass: | ||
name: All jobs pass | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
- lint | ||
- test | ||
- check-workflows | ||
steps: | ||
- run: echo "Great success!" |
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 file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish docs to GitHub Pages | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
destination_dir: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
publish-docs-to-gh-pages: | ||
name: Publish docs to GitHub Pages | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Ensure `destination_dir` is not empty | ||
if: ${{ inputs.destination_dir == '' }} | ||
run: exit 1 | ||
- name: Checkout the repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Get Yarn cache directory | ||
run: echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" | ||
id: yarn-cache-dir | ||
- name: Get Yarn version | ||
run: echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT" | ||
id: yarn-version | ||
- name: Cache yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }} | ||
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }} | ||
- name: Install npm dependencies | ||
run: yarn --immutable | ||
- name: Run build script | ||
run: yarn build:docs | ||
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch | ||
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs | ||
destination_dir: ${{ inputs.destination_dir }} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Publish main branch docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: main | ||
|
||
jobs: | ||
publish-to-gh-pages: | ||
name: Publish docs to `staging` directory of `gh-pages` branch | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/publish-docs.yml | ||
with: | ||
destination_dir: staging |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish release candidate docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: 'release/**' | ||
|
||
jobs: | ||
get-release-version: | ||
name: Get release version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-version: ${{ steps.release-name.outputs.RELEASE_VERSION }} | ||
steps: | ||
- name: Extract release version from branch name | ||
id: release-name | ||
run: | | ||
BRANCH_NAME='${{ github.ref_name }}' | ||
echo "RELEASE_VERSION=v${BRANCH_NAME#release/}" >> "$GITHUB_OUTPUT" | ||
publish-to-gh-pages: | ||
name: Publish docs to `rc-${{ needs.get-release-version.outputs.release-version }}` directory of `gh-pages` branch | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/publish-docs.yml | ||
needs: get-release-version | ||
with: | ||
destination_dir: rc-${{ needs.get-release-version.outputs.release-version }} |
Oops, something went wrong.