-
Notifications
You must be signed in to change notification settings - Fork 204
50 lines (42 loc) · 1.64 KB
/
develop-synced-dispatch.yml
File metadata and controls
50 lines (42 loc) · 1.64 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
name: Dispatch develop-synced after sync/main merged (Scheme A)
on:
pull_request:
types:
- closed
branches:
- develop
jobs:
dispatch_develop_synced:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'sync/main-')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Derive version from sync branch
id: version
run: |
set -euo pipefail
BRANCH="${{ github.event.pull_request.head.ref }}"
echo "Head branch: ${BRANCH}"
VERSION="${BRANCH#sync/main-}"
if [ -z "${VERSION}" ] || [ "${VERSION}" = "${BRANCH}" ]; then
echo "Failed to parse version from branch ${BRANCH}, skip dispatch."
echo "version=" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Parsed version: ${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Send repository_dispatch develop-synced
if: steps.version.outputs.version != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.version }}"
OWNER_REPO="${GITHUB_REPOSITORY}"
echo "Sending repository_dispatch develop-synced for version ${VERSION} to ${OWNER_REPO}"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${OWNER_REPO}/dispatches" \
-d "{\"event_type\":\"develop-synced\",\"client_payload\":{\"version\":\"${VERSION}\"}}"