From 01a465fa88b2ebd01f1c61363ef0dd6ce04bbcd0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 3 Mar 2023 17:53:56 +0000 Subject: [PATCH] Trigger schedule(nightly) builds on non default branches Signed-off-by: Pedro Algarvio --- .github/workflows/nightly.yml | 14 +++++++++ .github/workflows/templates/nightly.yml.jinja | 29 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 66a219441fe..4a8a28fb29e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -4,6 +4,7 @@ name: Nightly on: + workflow_dispatch: {} schedule: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule - cron: '0 3 * * *' # Every day at 3AM @@ -16,6 +17,7 @@ env: permissions: contents: read # for dorny/paths-filter to fetch a list of changed files pull-requests: read # for dorny/paths-filter to read pull requests + actions: write # to trigger branch nightly builds concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.repository }}-${{ github.head_ref || github.run_id }} @@ -23,6 +25,17 @@ concurrency: jobs: + trigger-branch-nightly-builds: + name: Trigger Branch Schedule Workflows + if: ${{ github.event_name == 'schedule' }} + runs-on: ubuntu-latest + steps: + - name: Trigger 3006.x branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh workflow run nightly.yml --repo ${{ github.repository }} --ref 3006.x + prepare-workflow: name: Prepare Workflow Run runs-on: ubuntu-latest @@ -1732,6 +1745,7 @@ jobs: if: always() runs-on: ubuntu-latest needs: + - trigger-branch-nightly-builds - prepare-workflow - pre-commit - lint diff --git a/.github/workflows/templates/nightly.yml.jinja b/.github/workflows/templates/nightly.yml.jinja index 142101306d2..d53447c504a 100644 --- a/.github/workflows/templates/nightly.yml.jinja +++ b/.github/workflows/templates/nightly.yml.jinja @@ -4,6 +4,7 @@ <%- block on %> on: + workflow_dispatch: {} schedule: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule - cron: '0 3 * * *' # Every day at 3AM @@ -18,6 +19,34 @@ concurrency: <%- endblock concurrency %> +<%- block permissions %> +<{- super() }> +<%- if workflow_slug == "nightly" %> + actions: write # to trigger branch nightly builds +<%- endif %> +<%- endblock permissions %> + +<%- block pre_jobs %> + + <%- set job_name = "trigger-branch-nightly-builds" %> + <%- set branches = ["3006.x"] %> + + <{ job_name }>: + <%- do conclusion_needs.append(job_name) %> + name: Trigger Branch Schedule Workflows + if: ${{ github.event_name == 'schedule' }} + runs-on: ubuntu-latest + steps: + <%- for branch in branches %> + - name: Trigger <{ branch }> branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh workflow run <{ gh_environment }>.yml --repo ${{ github.repository }} --ref <{ branch }> + <%- endfor %> + +<%- endblock pre_jobs %> + <%- block jobs %> <{- super() }>