Skip to content

Commit 6b76dc9

Browse files
committed
feat: add scheduled job to rebuild latest release Docker image
1 parent 70d09ec commit 6b76dc9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/docker-image.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: "Create and publish docker image"
33
on:
44
release:
55
types: [published]
6+
schedule:
7+
# Run at 2:00 AM UTC on the 1st of each month
8+
- cron: '0 2 1 * *'
69

710
permissions:
811
contents: read
@@ -12,8 +15,26 @@ jobs:
1215
build:
1316
runs-on: ubuntu-latest
1417
steps:
18+
- name: Get latest release tag
19+
if: github.event_name == 'schedule'
20+
id: latest_release
21+
run: |
22+
LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
23+
echo "RELEASE_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
24+
25+
- name: Set release tag variable
26+
id: release_tag
27+
run: |
28+
if [ "${{ github.event_name }}" == "schedule" ]; then
29+
echo "TAG=${{ steps.latest_release.outputs.RELEASE_TAG }}" >> $GITHUB_OUTPUT
30+
else
31+
echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
32+
fi
33+
1534
- name: Check out code
1635
uses: actions/checkout@v4
36+
with:
37+
ref: ${{ steps.release_tag.outputs.TAG }}
1738

1839
- name: Setup PHP
1940
uses: shivammathur/setup-php@v2
@@ -49,4 +70,4 @@ jobs:
4970
file: docker/php/package.Dockerfile
5071
push: true
5172
platforms: linux/amd64,linux/arm64
52-
tags: ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }},ghcr.io/${{ github.repository }}:latest
73+
tags: ghcr.io/${{ github.repository }}:${{ steps.release_tag.outputs.TAG }},ghcr.io/${{ github.repository }}:latest

0 commit comments

Comments
 (0)