Skip to content

Commit 9b12013

Browse files
authored
Update CI workflow to trigger on release events
1 parent 794e05c commit 9b12013

1 file changed

Lines changed: 43 additions & 35 deletions

File tree

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: CI - Build and Push to GHCR
22

33
on:
4-
push:
5-
branches: [ main ]
4+
release:
5+
types: [published]
66
workflow_dispatch:
7+
inputs:
8+
force_build:
9+
description: 'Force build and push'
10+
required: false
11+
default: 'false'
12+
type: boolean
713

814
env:
915
REGISTRY: ghcr.io
@@ -15,37 +21,39 @@ jobs:
1521
permissions:
1622
contents: read
1723
packages: write
18-
24+
1925
steps:
20-
- name: Checkout repository
21-
uses: actions/checkout@v4
22-
23-
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v3
25-
26-
- name: Log in to GitHub Container Registry
27-
uses: docker/login-action@v3
28-
with:
29-
registry: ${{ env.REGISTRY }}
30-
username: ${{ github.actor }}
31-
password: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Extract metadata (tags, labels)
34-
id: meta
35-
uses: docker/metadata-action@v5
36-
with:
37-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38-
# This will tag the main branch commit with 'latest'
39-
tags: |
40-
type=raw,value=latest,enable={{is_default_branch}}
41-
42-
- name: Build and push to GHCR
43-
uses: docker/build-push-action@v5
44-
with:
45-
context: .
46-
platforms: linux/amd64,linux/arm64
47-
push: true
48-
tags: ${{ steps.meta.outputs.tags }}
49-
labels: ${{ steps.meta.outputs.labels }}
50-
cache-from: type=gha
51-
cache-to: type=gha,mode=max
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata (tags, labels)
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=semver,pattern={{major}}
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: Build and push to GHCR
51+
uses: docker/build-push-action@v5
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)