Skip to content

Commit 85dfdd6

Browse files
committed
ci: switch to curl auto assign github action for forked PRs
1 parent ce1159d commit 85dfdd6

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

.github/workflows/auto_assign_pr.yml

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
name: 'Auto Assign PR'
22

33
on:
4+
workflow_call:
5+
46
workflow_run:
57
workflows: ["Pull Request Opened"]
68
types:
79
- completed
810

911
jobs:
10-
log-info:
11-
name: "Add reviewers to PR"
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: "echo variables"
15-
run: |
16-
echo \"${{ github.event.workflow_run.event }}\"
17-
echo \"${{ github.event.pull_request.types }}\"
18-
echo \"${{ github.actor }}\"
1912

2013
add-reviewers:
2114
name: "Add reviewers to PR"
@@ -54,24 +47,38 @@ jobs:
5447
var fs = require('fs');
5548
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
5649
- run: unzip pr.zip
50+
- name: 'Find PR Number'
51+
id: find-pr-number
52+
uses: actions/github-script@v6
53+
with:
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
script: |
56+
var fs = require('fs');
57+
var str = String(fs.readFileSync('./NR'));
58+
var array = str.split(',')
59+
return array[0]
60+
result-encoding: string
5761
- name: 'Find PR Title'
58-
id: find-pr
62+
id: find-pr-title
5963
uses: actions/github-script@v6
6064
with:
6165
github-token: ${{ secrets.GITHUB_TOKEN }}
6266
script: |
6367
var fs = require('fs');
64-
var titleString = String(fs.readFileSync('./NR'));
65-
return titleString
68+
var str = String(fs.readFileSync('./NR'));
69+
var array = str.split(',')
70+
return array[1]
6671
result-encoding: string
72+
- name: "Log PR Number"
73+
run: |
74+
echo "${{ steps.find-pr-number.outputs.result }}"
6775
- name: "Log PR Title"
6876
run: |
69-
echo "${{ steps.find-pr.outputs.result }}"
70-
77+
echo "${{ steps.find-pr-title.outputs.result }}"
7178
- name: "Check PR title"
7279
id: is-docs
7380
if: >
74-
startsWith(${{ steps.find-pr.outputs.result }}, 'docs:')
81+
startsWith(steps.find-pr-title.outputs.result, 'docs:')
7582
run: |
7683
OUTPUT=true
7784
echo "::set-output name=isDocs::$OUTPUT"
@@ -80,17 +87,20 @@ jobs:
8087
echo ${{ steps.is-docs.outputs.isDocs }}
8188
- name: "PR title is docs"
8289
if: ${{steps.is-docs.outputs.isDocs == 'true'}}
83-
uses: pozil/auto-assign-issue@v1
84-
with:
85-
teams: docs-triage
86-
numOfAssignee: 1
87-
allowSelfAssign: false
88-
repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}}
90+
run: |
91+
curl \
92+
-X POST \
93+
-H "Accept: application/vnd.github+json" \
94+
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
95+
https://api.github.com/repos/mParticle/mparticle-android-sample-apps/pulls/${{ steps.find-pr-number.outputs.result }}/requested_reviewers \
96+
-d '{"reviewers":["jasonmgeorge","MystiBerry"],"team_reviewers":["docs-triage"]}'
8997
- name: "PR title is not docs"
9098
if: ${{ steps.is-docs.outputs.isDocs != 'true'}}
91-
uses: pozil/auto-assign-issue@v1
92-
with:
93-
teams: android-triage
94-
numOfAssignee: 1
95-
allowSelfAssign: false
96-
repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}}
99+
run: |
100+
curl \
101+
-X POST \
102+
-H "Accept: application/vnd.github+json" \
103+
-H "Authorization: Bearer ${{secrets.MP_SEMANTIC_RELEASE_BOT}}" \
104+
https://api.github.com/repos/mParticle/mparticle-android-sample-apps/pulls/${{ steps.find-pr-number.outputs.result }}/requested_reviewers \
105+
-d '{"reviewers":["mchuangatmp","einsteinx2"],"team_reviewers":["android-triage"]}'
106+

.github/workflows/pull_request_opened.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: "Save Pull Request Number"
1818
run: |
1919
mkdir -p ./pr
20-
echo ${{ github.event.pull_request.title }} > ./pr/NR
20+
echo ${{ github.event.pull_request.number }},${{github.event.pull_request.title }} > ./pr/NR
2121
- uses: actions/upload-artifact@v2
2222
with:
2323
name: pr

0 commit comments

Comments
 (0)