Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit d42f707

Browse files
Merge pull request #66 from matter-labs/bh-evm-388-add-workflow-to-label-external-contributions
ci: add workflow to label external-contributions
2 parents a00ab9a + 6619454 commit d42f707

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Workflow to label external contributions
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
label:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Add external-contribution label
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: |
19+
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
20+
REPO_FULL_NAME=$(jq --raw-output .repository.full_name "$GITHUB_EVENT_PATH")
21+
IS_FORK=$(jq --raw-output .pull_request.head.repo.fork "$GITHUB_EVENT_PATH")
22+
23+
if [[ "$IS_FORK" == "true" ]]; then
24+
echo "This PR is created from a fork."
25+
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" \
26+
-X POST \
27+
-H "Authorization: Bearer $GITHUB_TOKEN" \
28+
-H "Accept: application/vnd.github.v3+json" \
29+
"https://api.github.com/repos/$REPO_FULL_NAME/issues/$PR_NUMBER/labels" \
30+
-d '{"labels": ["external-contribution"]}')
31+
32+
if [[ $HTTP_STATUS -ge 300 ]]; then
33+
echo "Failed to add label to PR, exiting."
34+
exit 1
35+
fi
36+
else
37+
echo "This PR is not created from a fork."
38+
fi

0 commit comments

Comments
 (0)