Skip to content

Create and publish a Docker image #8

Create and publish a Docker image

Create and publish a Docker image #8

Workflow file for this run

name: Create and publish a Docker image
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: gruppe-adler/arsa-frontend
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '23.x'
- name: Install Dependencies
run: npm ci
- name: Build Project
run: npm run build
- name: Upload Production-Ready Build Files
uses: actions/upload-artifact@v4
with:
name: production-files
path: ./dist
build-and-push-docker-image:
name: Build and Push Docker Image
needs: build-frontend
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: gruppe-adler/arsa-backend
- name: Download Production-Ready Build Files
uses: actions/download-artifact@v4
with:
name: production-files
path: ./app
- name: Log in to the Container registry
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 }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
build-args: |
DOCKER_GID=102
DOCKER_PORT=80
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true