Skip to content

Commit 0ee2541

Browse files
codexcodex
andcommitted
ci: split main and tag image publishing
Co-authored-by: Codex <[email protected]>
1 parent 978bf82 commit 0ee2541

2 files changed

Lines changed: 58 additions & 14 deletions

File tree

.github/workflows/publish-tag.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish tag
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Log in to Docker Hub
25+
uses: docker/login-action@v3
26+
with:
27+
username: ${{ secrets.DOCKER_HUB_USER }}
28+
password: ${{ secrets.DOCKER_HUB_PAT }}
29+
30+
- name: Set image tag
31+
run: |
32+
IMAGE_TAG="kuberhealthy/ssl-expiry-check:${GITHUB_REF_NAME}"
33+
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
34+
35+
- name: Build and push
36+
uses: docker/build-push-action@v6
37+
with:
38+
context: .
39+
file: ./Containerfile
40+
push: true
41+
tags: ${{ env.IMAGE_TAG }}
42+
43+
- name: Publish summary
44+
run: |
45+
echo "Images pushed:" >> "$GITHUB_STEP_SUMMARY"
46+
echo "- ${{ env.IMAGE_TAG }}" >> "$GITHUB_STEP_SUMMARY"

.github/workflows/publish.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
name: Publish
1+
name: Publish main
22

33
on:
44
push:
55
branches:
66
- main
7-
- master
8-
tags:
9-
- "v*"
107

118
jobs:
129
publish:
@@ -30,20 +27,21 @@ jobs:
3027
username: ${{ secrets.DOCKER_HUB_USER }}
3128
password: ${{ secrets.DOCKER_HUB_PAT }}
3229

33-
- name: Docker metadata
34-
id: meta
35-
uses: docker/metadata-action@v5
36-
with:
37-
images: kuberhealthy/ssl-expiry-check
38-
tags: |
39-
type=sha,format=short,prefix=,event=branch
40-
type=ref,event=tag
30+
- name: Set image tag
31+
run: |
32+
SHORT_SHA=$(git rev-parse --short HEAD)
33+
IMAGE_TAG="kuberhealthy/ssl-expiry-check:${SHORT_SHA}"
34+
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
4135
4236
- name: Build and push
4337
uses: docker/build-push-action@v6
4438
with:
4539
context: .
4640
file: ./Containerfile
4741
push: true
48-
tags: ${{ steps.meta.outputs.tags }}
49-
labels: ${{ steps.meta.outputs.labels }}
42+
tags: ${{ env.IMAGE_TAG }}
43+
44+
- name: Publish summary
45+
run: |
46+
echo "Images pushed:" >> "$GITHUB_STEP_SUMMARY"
47+
echo "- ${{ env.IMAGE_TAG }}" >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)