From 8a7dd7bee21c5d7ae1ae21c36c45890f90a950f9 Mon Sep 17 00:00:00 2001 From: Ben Adrian Sarmiento Date: Wed, 19 Jun 2024 11:03:45 +0200 Subject: [PATCH] Add nightly for Docker build --- .github/workflows/build.yml | 6 +++--- .github/workflows/build_docker.yml | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30d3221..344e228 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: tags: - '*' schedule: - - cron: '0 9 * * *' + - cron: '0 1 * * *' jobs: build: @@ -32,13 +32,13 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Check for New Commits (Nightly Only) + - name: Check for new commits (nightly only) id: check if: github.event_name == 'schedule' continue-on-error: false run: | # 3AM CET - since="$(date -d 'yesterday' +%Y-%m-%d) 09:00:00" + since="$(date -d 'yesterday' +%Y-%m-%d) 01:00:00" count=$(git rev-list --count --since="$since" --until=now HEAD) if [ "$count" -gt 0 ]; then echo "new_commits=true" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index e7b9578..feced69 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -4,6 +4,8 @@ on: push: tags: - '*' + schedule: + - cron: '0 1 * * *' jobs: build-and-push-image: @@ -17,10 +19,29 @@ jobs: - name: Check out code uses: actions/checkout@v4 + - name: Check for new commits (nightly only) + id: check + if: github.event_name == 'schedule' + continue-on-error: false + run: | + # 3AM CET + since="$(date -d 'yesterday' +%Y-%m-%d) 01:00:00" + count=$(git rev-list --count --since="$since" --until=now HEAD) + if [ "$count" -gt 0 ]; then + echo "new_commits=true" >> $GITHUB_OUTPUT + else + echo "no new commits found for nightly build" + exit 1 + fi + - name: Set version id: buildvars run: | - echo "version=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + if [ "${{ github.event_name }}" = "schedule" ]; then + echo "version=$(date +'%Y.%m.%d-nightly')" >> $GITHUB_OUTPUT + else + echo "version=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_OUTPUT + fi echo "built_at=$(date +%Y-%m-%dT%H:%M:%S)" >> $GITHUB_OUTPUT echo "git_commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT @@ -50,7 +71,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ghcr.io/${{ github.repository }}${{ !contains(github.ref, '-rc.') && '-testing' || '' }} + ghcr.io/${{ github.repository }}${{ !contains(github.ref, '-rc') && !contains(github.ref, '-nightly') && '-testing' || '' }} - name: Build and push Docker image uses: docker/build-push-action@v5