Skip to content

Fix commit link

Fix commit link #85

Workflow file for this run

name: Docker
on:
# schedule:
# - cron: '38 20 * * *'
push:
tags: [ 'v*.*.*' ]
branches:
- main
pull_request:
branches:
- main
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
name: Build and push image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy:
fail-fast: false
matrix:
project: [ 'API', 'Worker', 'Frontend' ]
steps:
- name: Checkout target branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch main branch
run: git fetch origin main:main
- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.project }}
- name: Build and push Docker image (${{ matrix.project }})
id: push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.project == 'API' && 'Backend/PubNet.API' || matrix.project == 'Worker' && 'Worker/PubNet.Worker' || 'Frontend/PubNet.Client.Web' }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
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}}/${{ matrix.project }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: ${{ github.event_name != 'pull_request' }}