From 230f505806a7278ea5e61de8aba78a41833ca63b Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Thu, 19 Sep 2024 16:31:37 -0400 Subject: [PATCH] cd: optimize nightly Add check to only run nightly if changes in the past 24 hours --- .github/workflows/check-date.yml | 20 +++++++++++++++++++ .github/workflows/nightly.yml | 17 ++++++++++++++++ .../{issue-workflow.yml => on-issue.yml} | 6 +++--- .../{publish-workflow.yml => on-publish.yml} | 6 +++--- .github/workflows/release.yml | 5 ++--- 5 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/check-date.yml create mode 100644 .github/workflows/nightly.yml rename .github/workflows/{issue-workflow.yml => on-issue.yml} (92%) rename .github/workflows/{publish-workflow.yml => on-publish.yml} (91%) diff --git a/.github/workflows/check-date.yml b/.github/workflows/check-date.yml new file mode 100644 index 0000000..62227f4 --- /dev/null +++ b/.github/workflows/check-date.yml @@ -0,0 +1,20 @@ +name: check-date + +on: + workflow_dispatch: + +jobs: + check_date: + runs-on: ubuntu-latest + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v2 + - name: print latest_commit + run: echo ${{ github.sha }} + - id: should_run + continue-on-error: true + name: check latest commit is less than a day + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="23 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..29e9299 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,17 @@ +name: nightly + +on: + schedule: + - cron: "4 3 * * *" +jobs: + nightly-publish-check: + name: Nightly publish check + runs-on: ubuntu-latest + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false' }} + steps: + - name: Build and publish nightly + uses: ./.github/workflows/release.yml + secrets: inherit + with: + build_type: ${{ inputs.release_type == '' && 'nightly' || inputs.release_type }} diff --git a/.github/workflows/issue-workflow.yml b/.github/workflows/on-issue.yml similarity index 92% rename from .github/workflows/issue-workflow.yml rename to .github/workflows/on-issue.yml index 5edc689..b793c8c 100644 --- a/.github/workflows/issue-workflow.yml +++ b/.github/workflows/on-issue.yml @@ -1,4 +1,4 @@ -name: Issue Updates Workflow +name: on-issue on: issues: @@ -7,8 +7,8 @@ on: jobs: - build: - name: Build + on-issue: + name: On new issue runs-on: ubuntu-latest steps: - name: Send Telegram Message diff --git a/.github/workflows/publish-workflow.yml b/.github/workflows/on-publish.yml similarity index 91% rename from .github/workflows/publish-workflow.yml rename to .github/workflows/on-publish.yml index 1fcb05c..ad59a42 100644 --- a/.github/workflows/publish-workflow.yml +++ b/.github/workflows/on-publish.yml @@ -1,4 +1,4 @@ -name: Release Updates Workflow +name: on-publish on: release: @@ -7,8 +7,8 @@ on: jobs: - build: - name: Build + on-publish: + name: On publish runs-on: ubuntu-latest steps: - name: Send Telegram Message diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7b7e96..a27c8f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,6 @@ name: release-android on: - schedule: - - cron: "4 3 * * *" workflow_dispatch: inputs: track: @@ -34,7 +32,8 @@ on: jobs: build: name: Build Signed APK - if: ${{ inputs.release_type != 'none' }} + needs: check_date + if: ${{ inputs.release_type != 'none' && (needs.check_date.outputs.should_run != 'false' && ) }} runs-on: ubuntu-latest env: