From 3fa1f443d3943e394ddb9f3dc61ca9eba7342ad1 Mon Sep 17 00:00:00 2001 From: Ben Adrian Sarmiento Date: Wed, 19 Jun 2024 00:50:27 +0200 Subject: [PATCH] Add support for nightly builds --- .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a7ac64..826a9d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,8 @@ on: push: tags: - '*' + schedule: + - cron: '*/15 * * * *' jobs: build: @@ -30,10 +32,30 @@ 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 + # date -d 'yesterday' +%Y-%m-%dT02:00:0 + since="$(date -d 'yesterday' +%Y-%m-%d) 02: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: Generate build variables id: prep 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 @@ -91,7 +113,12 @@ jobs: steps: - name: Set version id: version - run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/tags/})" + run: | + 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 - name: Download artifacts uses: actions/download-artifact@v3