mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-19 16:54:15 +02:00
feat: add Docker workflows for building and pushing frontend and backend images
This commit is contained in:
57
.github/workflows/build-push-frontend.yml
vendored
Normal file
57
.github/workflows/build-push-frontend.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Build and Push Frontend Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Adjust if your default branch is different
|
||||
tags:
|
||||
- 'v*.*.*' # Triggers on version tags like v1.0.0
|
||||
paths:
|
||||
- 'web/**' # Only run if files in web/ directory change
|
||||
- '.github/workflows/build-push-frontend.yml' # Or if the workflow itself changes
|
||||
workflow_dispatch: # Allows manual triggering from the Actions tab
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read # To checkout the repository
|
||||
packages: write # To push Docker images to GHCR
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/frontend
|
||||
tags: |
|
||||
# set latest tag for default branch
|
||||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
||||
# tag event 'refs/tags/v1.0.0' will generate 'v1.0.0'
|
||||
type=ref,event=tag
|
||||
# branch event 'refs/heads/main' will generate 'main'
|
||||
type=ref,event=branch
|
||||
# sha
|
||||
type=sha
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./web
|
||||
file: ./web/Dockerfile
|
||||
push: ${{ github.event_name != 'pull_request' }} # Do not push on PRs
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
VERSION=${{ steps.meta.outputs.version }} # This will be the git tag (e.g. v1.0.0) or branch name or sha
|
||||
|
||||
Reference in New Issue
Block a user