forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (79 loc) · 3.47 KB
/
Copy pathnightly-trigger.yml
File metadata and controls
89 lines (79 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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
});