Skip to content

Commit 63e8645

Browse files
ci: PLT-527: Add Adala Follow Merge Dispatch
1 parent 6114a72 commit 63e8645

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 'Follow Merge: Sync PR Adala'
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- closed
8+
- converted_to_draft
9+
- ready_for_review
10+
- synchronize
11+
branches:
12+
- master
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.head_ref }}
16+
17+
env:
18+
DOWNSTREAM_REPOSITORY: "Adala"
19+
20+
jobs:
21+
sync:
22+
name: "Sync"
23+
if: startsWith(github.head_ref, 'fb-')
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: hmarr/[email protected]
27+
28+
- name: Check user's membership
29+
if: github.actor != 'fern-api[bot]'
30+
uses: actions/github-script@v7
31+
id: check-membership
32+
with:
33+
github-token: ${{ secrets.GIT_PAT }}
34+
script: |
35+
const { repo, owner } = context.repo;
36+
try {
37+
return (await github.rest.orgs.getMembershipForUser({
38+
org: owner,
39+
username: '${{ github.actor }}',
40+
}))?.data?.state == "active";
41+
} catch (error) {
42+
return false;
43+
}
44+
45+
- name: Notify user on failure
46+
if: steps.check-membership.outputs.result == 'false'
47+
uses: actions/github-script@v7
48+
with:
49+
github-token: ${{ secrets.GIT_PAT }}
50+
script: |
51+
const { repo, owner } = context.repo;
52+
const result = await github.rest.issues.createComment({
53+
owner,
54+
repo,
55+
issue_number: '${{ github.event.number }}',
56+
body: [
57+
'Hi @${{ github.actor }}!',
58+
'',
59+
`Unfortunately you don't have membership in ${owner} organization, your PR wasn't synced with ${owner}/${{ env.DOWNSTREAM_REPOSITORY }}.`
60+
].join('\n')
61+
});
62+
throw `${{ github.actor }} don't have membership in ${owner} organization`
63+
64+
- name: Checkout Actions Hub
65+
uses: actions/checkout@v4
66+
with:
67+
token: ${{ secrets.GIT_PAT }}
68+
repository: HumanSignal/actions-hub
69+
path: ./.github/actions-hub
70+
71+
- name: Dispatch Follow Merge Event
72+
uses: ./.github/actions-hub/actions/follow-merge-dispatch
73+
with:
74+
github_token: ${{ secrets.GIT_PAT }}
75+
downstream_repository: "${{ env.DOWNSTREAM_REPOSITORY }}"

0 commit comments

Comments
 (0)