Skip to content

Commit dda337d

Browse files
committed
Create a Git tag on push to main
1 parent f17d392 commit dda337d

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,31 @@ jobs:
1919
name: Build and push Docker image
2020
runs-on: ubuntu-latest
2121
permissions:
22-
contents: read
22+
contents: write
2323
packages: write
2424
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
with:
28+
fetch-depth: 0
29+
2530
# Generate Docker tags, labels and annotations
2631
- name: Docker meta
2732
id: meta
2833
uses: docker/metadata-action@v5
2934
with:
3035
images: ghcr.io/${{ github.repository_owner }}/startsch
3136
tags: |
32-
# Use the GitHub action run number as the version.
37+
# Tag the Docker image using a version created from the GitHub action run number.
3338
# Using the Git hash as the tag does not work because Renovate does not know how to find the latest version.
3439
# Using just :latest with a @sha256:IMAGE_HASH does not work as digest updates do not add a GitHub diff link to the Renovate PR for some reason.
35-
type=raw,value=0.0.${{ github.run_number }}
40+
type=raw,value=v0.0.${{ github.run_number }}
3641
37-
# Add latest tag when running on main
38-
type=raw,value=latest,enable={{is_default_branch}}
42+
# Add latest tag
43+
type=raw,value=latest
44+
45+
# Tag with Git commit hash
46+
type=sha,format=long
3947
4048
- name: Log in to the Container registry
4149
uses: docker/login-action@v3
@@ -58,6 +66,15 @@ jobs:
5866
annotations: ${{ steps.meta.outputs.annotations }}
5967
cache-from: type=gha
6068
cache-to: type=gha,mode=max
69+
70+
# Renovate needs a Git tag to show a GitHub diff link
71+
- name: Create Git tag
72+
run: |
73+
TAG_NAME="v0.0.${{ github.run_number }}"
74+
git config user.name "github-actions[bot]"
75+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
76+
git tag "$TAG_NAME"
77+
git push origin "$TAG_NAME"
6178
6279
update-k8s:
6380
name: Update kir-dev/k8s
@@ -78,5 +95,5 @@ jobs:
7895
configurationFile: .github/workflows/renovate-global.js
7996
token: ${{ secrets.KIR_DEV_BOT_PAT }}
8097
env:
81-
# LOG_LEVEL: debug
98+
LOG_LEVEL: debug
8299
RENOVATE_TOKEN: ${{ secrets.KIR_DEV_BOT_PAT }}

0 commit comments

Comments
 (0)