Skip to content

Commit cc8d54b

Browse files
committed
Add nightly schedule to Docker CD workflow
Added a daily schedule to the Docker workflow to automate builds and pushes of the `daily-testing` image. This change introduces a new cron job that runs every day at midnight (UTC) and triggers the workflow. Additionally, updated the workflow to set different environment variables for daily builds, including `RELEASE_VERSION` and `IMAGE_TAG`. These changes enable the automatic creation of daily testing images with unique tags. Inspired by: https://github.com/lightningnetwork/lnd/blob/57a5e4912bced63ce13be06896f64d7e476616b4/.github/workflows/docker.yml#L7-L44
1 parent 272409d commit cc8d54b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.github/workflows/docker.yml

+21-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
tags:
66
- 'v*'
7-
7+
schedule:
8+
# Every day at midnight (UTC).
9+
- cron: '0 0 * * *'
810

911
defaults:
1012
run:
@@ -31,7 +33,15 @@ jobs:
3133
password: ${{ secrets.DOCKER_API_KEY }}
3234

3335
- name: Set env
34-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
36+
run: |
37+
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
38+
echo "IMAGE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
39+
40+
- name: Set daily tag
41+
if: github.event.schedule == '0 0 * * *'
42+
run: |
43+
echo "RELEASE_VERSION=master" >> $GITHUB_ENV
44+
echo "IMAGE_TAG=daily-testing-$(date -u +%Y%m%d),${DOCKER_REPO}/${DOCKER_IMAGE}:daily-testing-only" >> $GITHUB_ENV
3545
3646
- name: Build and push default image
3747
id: docker_build
@@ -53,5 +63,14 @@ jobs:
5363
checkout=${{ env.RELEASE_VERSION }}
5464
public_url=/lit
5565
66+
- name: Build and push nightly-build image
67+
id: docker_build
68+
uses: lightninglabs/gh-actions/[email protected]
69+
with:
70+
push: true
71+
platforms: linux/amd64,linux/arm64
72+
tags: "${{ env.DOCKER_REPO }}/${{ env.DOCKER_IMAGE }}:${{ env.IMAGE_TAG }}"
73+
build-args: checkout=${{ env.RELEASE_VERSION }}
74+
5675
- name: Image digest
5776
run: echo ${{ steps.docker_build.outputs.digest }} ${{ steps.docker_build2.outputs.digest }}

0 commit comments

Comments
 (0)