-
Notifications
You must be signed in to change notification settings - Fork 61
57 lines (49 loc) · 2.3 KB
/
ort-sweeper.yml
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
name: ORT - Trigger periodic checks for relevant branches
on:
schedule:
- cron: "0 0 * * *" # Runs daily at 00:00 UTC
jobs:
trigger-ort-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch relevant branches
id: get-branches
run: |
# Get all branches matching 'release-*' and include 'main'
branches=$(git ls-remote --heads origin | awk -F'/' '/refs\/heads\/release-/ {printf $NF" "}')
branches="main $branches"
echo "::set-output name=branches::$branches"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger ORT Check workflows
uses: actions/github-script@v6
with:
script: |
const branches = "${{ steps.get-branches.outputs.branches }}".split(" ");
const workflowFile = "ort.yml";
const triggerWorkflow = async (branch) => {
try {
console.log(`Triggering workflow for branch: ${branch}`);
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflowFile,
ref: branch, // The branch where workflow_dispatch is triggered
inputs: {
branch_name: branch
}
});
console.log(`Successfully triggered workflow for branch: ${branch}`);
} catch (error) {
core.setFailed(error.message);
}
};
// Fire all workflow dispatch requests concurrently
const promises = branches
.filter(branch => branch) // Skip empty branches
.map(branch => triggerWorkflow(branch));
await Promise.allSettled(promises);
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}