Update .github/workflows/docker-build.yml

This commit is contained in:
damien 2025-02-27 01:02:28 +00:00
parent 289654c9c8
commit 0035a51c5c

View File

@ -1,16 +1,15 @@
name: Build and Push Docker Image
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version to tag the image with (e.g., 1.0.0)'
required: true
type: string
jobs:
build:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write # Allows tagging and releasing
@ -51,40 +50,25 @@ jobs:
with:
images: ${{ github.server_url }}/${{ github.repository }}/personal-website
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Determine version
id: semver
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.PACKAGE_TOKEN }}
release_branches: main
default_bump: patch
dry_run: true
type=raw,value=${{ github.event.inputs.version }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: |
${{ github.server_url }}/${{ github.repository }}/personal-website:latest
${{ github.server_url }}/${{ github.repository }}/personal-website:${{ steps.semver.outputs.new_tag }}
${{ github.server_url }}/${{ github.repository }}/personal-website:${{ github.event.inputs.version }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create GitHub Release
if: github.event_name != 'pull_request'
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.event.inputs.version }}
release_branches: main
default_bump: patch
create_annotated_tag: true
tag_prefix: v
tag_prefix: v