Skip to content

Commit 2605b4d

Browse files
committed
feat: update workflows to support manual triggering and enhance Docker image build process
1 parent f3b2394 commit 2605b4d

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Build and Publish Container Image
22

33
on:
44
push:
5-
branches: [ main ]
65
tags: [ 'v*' ]
6+
workflow_dispatch: # Allow manual triggering
77

88
env:
99
REGISTRY: ghcr.io
@@ -16,7 +16,7 @@ jobs:
1616
build-and-push:
1717
needs: ci
1818
runs-on: ubuntu-latest
19-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
19+
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
2020
permissions:
2121
contents: read
2222
packages: write

.github/workflows/release-please.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ permissions:
77
contents: write
88
issues: write
99
pull-requests: write
10+
packages: write
1011

1112
name: release-please
1213

14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ${{ github.repository }}
17+
1318
jobs:
1419
release-please:
1520
runs-on: ubuntu-latest
@@ -48,4 +53,42 @@ jobs:
4853
notion-md-linux-arm64 \
4954
notion-md-darwin-amd64 \
5055
notion-md-darwin-arm64 \
51-
notion-md-windows-amd64.exe
56+
notion-md-windows-amd64.exe
57+
58+
# Build and push Docker image for releases
59+
- name: Set up Docker Buildx
60+
if: ${{ steps.release.outputs.release_created }}
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Log in to Container Registry
64+
if: ${{ steps.release.outputs.release_created }}
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ${{ env.REGISTRY }}
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Extract metadata for Docker
72+
if: ${{ steps.release.outputs.release_created }}
73+
id: meta
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
77+
tags: |
78+
type=semver,pattern={{version}},value=${{ steps.release.outputs.tag_name }}
79+
type=semver,pattern={{major}}.{{minor}},value=${{ steps.release.outputs.tag_name }}
80+
type=semver,pattern={{major}},value=${{ steps.release.outputs.tag_name }}
81+
type=raw,value=latest
82+
83+
- name: Build and push Docker image
84+
if: ${{ steps.release.outputs.release_created }}
85+
uses: docker/build-push-action@v5
86+
with:
87+
context: .
88+
file: ./Containerfile
89+
platforms: linux/amd64,linux/arm64
90+
push: true
91+
tags: ${{ steps.meta.outputs.tags }}
92+
labels: ${{ steps.meta.outputs.labels }}
93+
cache-from: type=gha
94+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)