mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-13 03:13:45 +02:00
58 lines
2.2 KiB
YAML
58 lines
2.2 KiB
YAML
name: Docker Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # Löst den Workflow bei jedem Push auf den main-Branch aus
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write # Notwendig, um in die GHCR zu pushen
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Notwendig, um den Git-Hash zu bekommen
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Get Git commit SHA
|
|
id: git_sha
|
|
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Define Image Names
|
|
id: image_names
|
|
run: |
|
|
echo "backend_image=ghcr.io/${{ github.repository_owner }}/utools-backend" >> $GITHUB_OUTPUT
|
|
echo "frontend_image=ghcr.io/${{ github.repository_owner }}/utools-frontend" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build images using compose.build.yml
|
|
env:
|
|
GIT_COMMIT_SHA: ${{ steps.git_sha.outputs.sha }}
|
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} # Sentry DSN als Secret übergeben
|
|
run: |
|
|
docker compose -f compose.build.yml build
|
|
|
|
- name: Tag images with Git SHA
|
|
run: |
|
|
docker tag ${{ steps.image_names.outputs.backend_image }}:latest ${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
|
docker tag ${{ steps.image_names.outputs.frontend_image }}:latest ${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }}
|
|
|
|
- name: Push images to GHCR (both tags)
|
|
run: |
|
|
docker push ${{ steps.image_names.outputs.backend_image }}:latest
|
|
docker push ${{ steps.image_names.outputs.backend_image }}:${{ steps.git_sha.outputs.sha }}
|
|
docker push ${{ steps.image_names.outputs.frontend_image }}:latest
|
|
docker push ${{ steps.image_names.outputs.frontend_image }}:${{ steps.git_sha.outputs.sha }} |