Nightly trigger (beta) #966
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF licenses this file to You under the Apache License, Version 2.0 | |
| # (the "License"); you may not use this file except in compliance with | |
| # the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # This workflow is meant as an extended CI run that includes certain features that shall be tested | |
| # and JDK versions that are supported but not considered default. | |
| name: "Nightly trigger (beta)" | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| Trigger: | |
| if: github.repository == 'apache/flink' | |
| permissions: | |
| actions: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ matrix.branch }} | |
| cancel-in-progress: true | |
| strategy: | |
| matrix: | |
| branch: | |
| - master | |
| - release-2.3 | |
| - release-1.20 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| sparse-checkout: | | |
| .github/actions/last_workflow_run | |
| - name: "Resolve last nightly run" | |
| id: last-nightly | |
| uses: "./.github/actions/last_workflow_run" | |
| with: | |
| workflow_id: "nightly.yml" | |
| branch: ${{ matrix.branch }} | |
| - name: Trigger Workflow | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const branch = '${{ matrix.branch }}'; | |
| // Resolve the current HEAD of the branch. | |
| const { data: branchData } = await github.rest.repos.getBranch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| branch: branch | |
| }); | |
| const currentSha = branchData.commit.sha; | |
| // Compare SHA from last nightly against current | |
| // if it is same, then no need to run nightly for the same SHA again. | |
| const lastBuiltSha = '${{ steps.last-nightly.outputs.sha }}' || undefined; | |
| const lastConclusion = '${{ steps.last-nightly.outputs.conclusion }}' || undefined; | |
| // Skip the scheduled run only if there are no new commits AND the | |
| // previous nightly was green. If the last run failed/was cancelled, | |
| // re-run even without new commits so failures get retried. | |
| // It is still possible to run manually even if the last one was green and no new commits. | |
| if (context.eventName === 'schedule' && lastBuiltSha === currentSha && lastConclusion === 'success') { | |
| core.info(`No new commits on ${branch} since ${currentSha} and last nightly was green, skipping scheduled nightly.`); | |
| return; | |
| } | |
| core.info(`Triggering nightly on ${branch} at ${currentSha} (last built: ${lastBuiltSha ?? 'none'}, last conclusion: ${lastConclusion ?? 'none'}).`); | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'nightly.yml', | |
| ref: branch | |
| }); |