Skip to content

Move where continue-on-error is applied #101

Move where continue-on-error is applied

Move where continue-on-error is applied #101

Workflow file for this run

---
name: "Node.js CI"
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
build:
runs-on: "ubuntu-22.04"
outputs:
node-version: ${{ steps.setup-node.outputs.node-version }}
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Set up Node environment"
uses: "actions/setup-node@v4"
id: "setup-node"
with:
cache: "npm"
node-version-file: ".nvmrc"
- name: "Install dependencies"
run: "npm ci"
- name: "Check code style"
run: "npm run lint"
- name: "Run tests and report coverage"
uses: "./.github/actions/test-coverage"
with:
reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: "Build package"
run: "npm run build"
- name: "Store build output"
uses: "actions/upload-artifact@v4"
with:
if-no-files-found: "error"
name: "fauxauth-lib"
path: "packages/fauxauth/lib"
e2e:
needs:
- "build"
strategy:
matrix:
node-version:
- "18.0"
- ${{ needs.build.outputs.node-version }}
- "lts/hydrogen"
- "lts/iron"
- "lts/jod"
- "latest"
uses: "./.github/workflows/e2e.yml"
with:
artifact-name: "fauxauth-lib"
continue-on-error: ${{ matrix.node-version == 'latest' }}
node-version: ${{ matrix.node-version }}
deploy-docker:
needs:
- "e2e"
if: startsWith(github.ref, 'refs/tags/v')
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Get metadata"
id: metadata
run: |
echo "major="$(echo "$TAG" | cut -d. -f1)"" >> $GITHUB_OUTPUT
echo "minor="$(echo "$TAG" | cut -d. -f2)"" >> $GITHUB_OUTPUT
echo "node=$(cat .nvmrc)" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
env:
TAG: ${{ github.ref_name }}
- name: "Set up Docker BuildX"
uses: "docker/setup-buildx-action@v3"
- name: "Log in to Docker Hub"
uses: docker/login-action@v3
with:
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKER_USERNAME }}
- name: "Build and push container"
uses: "docker/build-push-action@v5"
with:
build-args: |
ALPINE_RELEASE=3.19
NODE_RELEASE=${{ steps.metadata.outputs.node }}
context: .
labels: |
version=${{ github.ref_name }}
push: true
sbom: true
tags: |
textbook/fauxauth
textbook/fauxauth:${{ steps.metadata.outputs.major }}
textbook/fauxauth:${{ steps.metadata.outputs.major }}.${{ steps.metadata.outputs.minor }}
textbook/fauxauth:${{ steps.metadata.outputs.tag }}
- name: "Update Docker Hub description"
uses: "peter-evans/dockerhub-description@v4"
with:
password: ${{ secrets.DOCKER_PASSWORD }}
repository: "textbook/fauxauth"
username: ${{ secrets.DOCKER_USERNAME }}
deploy-github:
needs:
- "e2e"
if: startsWith(github.ref, 'refs/tags/v')
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Retrieve build output"
uses: "actions/download-artifact@v4"
with:
name: "fauxauth-lib"
path: "packages/fauxauth/lib"
- name: "Include LICENSE and README"
run: "cp LICENSE README.md packages/fauxauth/"
- name: "Set up Node environment"
uses: "actions/setup-node@v4"
id: "setup-node"
with:
node-version-file: ".nvmrc"
- name: "Create package"
run: "npm --workspace packages/fauxauth pack"
- name: "Publish to GitHub"
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create \
'${{ github.ref_name }}' \
--title '${{ github.ref_name }}' \
"fauxauth-$(jq --raw-output '.version' package.json).tgz#NPM package"
deploy-npm:
needs:
- "e2e"
if: startsWith(github.ref, 'refs/tags/v')
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Retrieve build output"
uses: "actions/download-artifact@v4"
with:
name: "fauxauth-lib"
path: "packages/fauxauth/lib"
- name: "Include LICENSE and README"
run: "cp LICENSE README.md packages/fauxauth/"
- name: "Set up Node environment"
uses: "actions/setup-node@v4"
id: "setup-node"
with:
node-version-file: ".nvmrc"
- name: "Publish to NPM"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > "$HOME/.npmrc"
npm --workspace packages/fauxauth publish
smoke-test:
needs:
- "deploy-docker"
- "deploy-npm"
runs-on: "ubuntu-22.04"
steps:
- name: "Check out repository"
uses: "actions/checkout@v4"
- name: "Validate published artifacts"
run: |
./bin/smoke-test.sh "${{ github.ref_name }}"