fix: upgrade docker image to node:20-alpine
#84
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: Build | |
on: | |
push: | |
jobs: | |
build: # to work as an action out of the box the ncc-build must be committed | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: bahmutov/npm-install@v1 | |
- run: yarn build | |
- run: git add -f build | |
- name: Commit build if it changed | |
run: > | |
git diff --staged --quiet | |
|| (git config user.name "github-actions" | |
&& git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
&& git commit -m "build: autoupdate" | |
&& echo "buildCommit=$(git rev-parse HEAD)" >>$GITHUB_ENV) | |
- if: env.buildCommit # skip if the build adds nothing new | |
name: Push build branch | |
run: git push -f origin HEAD:build | |
outputs: | |
buildCommit: ${{ env.buildCommit }} | |
verify: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ needs.build.outputs.buildCommit }} # if there is no buildCommit, checkout HEAD | |
- name: Dry-run | |
uses: ./ | |
with: | |
dry: true | |
debug: true | |
# if there is a buildCommit, push it back onto the branch that triggered the workflow | |
- if: needs.build.outputs.buildCommit | |
id: helper | |
uses: ph-fritsche/action-helper@master | |
- if: needs.build.outputs.buildCommit | |
name: Push back to original branch | |
run: | | |
git fetch --depth=2 origin ${{ needs.build.outputs.buildCommit }} | |
git log --format=oneline -n2 ${{ needs.build.outputs.buildCommit }} | |
git push -v origin ${{ needs.build.outputs.buildCommit }}:${{ steps.helper.outputs.branchName }} | |
release: | |
needs: [build, verify] | |
if: contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha', github.ref) | |
runs-on: ubuntu-latest | |
steps: | |
- id: helper | |
uses: ph-fritsche/action-helper@master | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.helper.outputs.branchName }} | |
- name: Ensure branch HEAD did not move | |
run: | | |
EXPECTED="${{ needs.build.outputs.buildCommit || github.sha }}" | |
ACTUAL="$(git rev-parse HEAD)" | |
if [ $ACTUAL != $EXPECTED ]; then | |
echo "::error ::HEAD moved to ${ACTUAL} - expected ${EXPECTED}" | |
exit 1 | |
fi | |
- id: release | |
name: Dogfooding release | |
uses: ./ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Add check to the build | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
const [owner, repo] = "${{ github.repository }}".split('/') | |
const outcome = "${{ steps.release.outcome }}" | |
const version = "${{ steps.release.outputs.version }}" | |
const gitTag = "${{ steps.release.outputs.gitTag }}" | |
const releaseUrl = version ? "https://github.com/${{ github.repository }}/releases/tag/" + gitTag : undefined | |
const runUrl = "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
await github.checks.create({ | |
owner, | |
repo, | |
head_sha: "${{ needs.build.outputs.buildCommit || github.sha }}", | |
name: version ? "release " + version : "release", | |
conclusion: (outcome === 'success' && !version) ? "skipped" : outcome, | |
details_url: releaseUrl || runUrl, | |
output: { | |
title: "release", | |
summary: version | |
? `Released as [${version}](${releaseUrl})` | |
: "Release skipped", | |
text: `see ${runUrl}`, | |
} | |
}) |