Workflow file for this run
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 project, then Docker Image and publish to Github Artifact Registry | |
on: | |
push: | |
# Publish semver tags as releases. | |
tags: ['v*.*.*'] | |
env: | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: Build from source to dist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- run: yarn install | |
- run: yarn build | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Upload node_modules | |
uses: actions/upload-artifact@v4 | |
with: | |
name: node_modules | |
path: node_modules | |
docker: | |
name: Build Docker Image and publish to Github Artifact Registry | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: ↙️ Download dist | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: ↙️ Download node_modules | |
uses: actions/download-artifact@v4 | |
with: | |
name: node_modules | |
path: node_modules | |
- uses: docker/setup-buildx-action@v3 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.build-and-push.outputs.digest }} | |
push-to-registry: true |