forked from PedestrianDynamics/PedPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweekly-dispatch-latest-release.yml
More file actions
50 lines (46 loc) · 1.86 KB
/
weekly-dispatch-latest-release.yml
File metadata and controls
50 lines (46 loc) · 1.86 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
on:
schedule:
- cron: '0 3 * * 0' # weekly Sunday 03:00 UTC — adjust as needed
workflow_dispatch: {}
permissions:
contents: read
actions: write
jobs:
dispatch-ci:
runs-on: ubuntu-latest
steps:
- name: Find latest rls-* branch
id: find_branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${{ github.repository }}/branches?per_page=100" \
| jq -r '.[] | select(.name|startswith("rls-")) | "\(.name)\t\(.commit.commit.author.date)"' \
| sort -t $'\t' -k2 \
| tail -n1 \
| cut -f1)
if [ -z "$latest" ]; then
echo "No rls-* branch found, exiting."
echo "found_branch=" >> $GITHUB_OUTPUT
exit 0
fi
echo "found_branch=$latest" >> $GITHUB_OUTPUT
- name: Dispatch CI workflow on that branch
if: steps.find_branch.outputs.found_branch != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Set WORKFLOW_FILE to the workflow filename you want to run on the rls branch.
# For example, if the workflow in the release branch is .github/workflows/ci.yml,
# set WORKFLOW_FILE="ci.yml"
WORKFLOW_FILE="ci.yml"
TARGET_REF="${{ steps.find_branch.outputs.found_branch }}"
echo "Dispatching workflow ${WORKFLOW_FILE} on ref ${TARGET_REF}"
curl -s -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/${WORKFLOW_FILE}/dispatches" \
-d "{\"ref\":\"${TARGET_REF}\"}" \
| jq .