Skip to content

Commit

Permalink
[FLINK-34989][ci] Reduce the number of nightly runs per day
Browse files Browse the repository at this point in the history
We only want to have master run every day. The release branches should be limited to one run every 3rd day.
  • Loading branch information
XComp committed Apr 2, 2024
1 parent 293905e commit f048df0
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions .github/workflows/nightly-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,51 @@ jobs:
- release-1.18
runs-on: ubuntu-latest
steps:
- name: Trigger Workflow
- name: "Flink Checkout"
uses: actions/checkout@v4
with:
persist-credentials: false

- name: "Select release branch for nightly run"
id: select_release_branch
run: |
release_branches_ordered_by_version="$(git branch -r | grep upstream | grep 'release-[1-9]\.[0-9]*$' | sort --field-separator '-' --key 2V | grep -o '[^/]*$')"
newest_release_branch="$(echo $release_branches_ordered_by_version | tail -1 | head -1)"
stable_release_branch="$(echo $release_branches_ordered_by_version | tail -2 | head -1)"
day_of_year="$(date +%j)"
echo "Day of year: $day_of_year"
release_branch = none
# each release branch should run every 3rd day to reduce load on the Apache Infra runners
if [[ "$(( $day_of_year % 3))" -eq 1 ]]; then
release_branch="${newest_release_branch}"
else if [[ "$(( $day_of_year % 3))" -eq 2 ]]; then
release_branch="${stable_release_branch}"
fi
echo "$release_branch selected for nightly run"
echo "release_branch=${release_branch}" >> ${GITHUB_OUTPUT}
# master should still run every day
- name: Trigger master nightly
uses: actions/github-script@v7
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'nightly.yml',
ref: 'master'
})
- name: Trigger release branch nightly
uses: actions/github-script@v7
if: ${{ steps.select_release_branch.release_branch != "none" }}
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'nightly.yml',
ref: '${{ matrix.branch }}'
ref: '${{ steps.select_release_branch.release_branch }}'
})

0 comments on commit f048df0

Please sign in to comment.