Skip to content

Commit

Permalink
Merge pull request #66 from matter-labs/bh-evm-388-add-workflow-to-la…
Browse files Browse the repository at this point in the history
…bel-external-contributions

ci: add workflow to label external-contributions
  • Loading branch information
StanislavBreadless authored Nov 15, 2023
2 parents a00ab9a + 6619454 commit d42f707
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/label-external-contributions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Workflow to label external contributions

on:
pull_request_target:
types: [opened, ready_for_review]

permissions:
contents: read
pull-requests: write

jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Add external-contribution label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
REPO_FULL_NAME=$(jq --raw-output .repository.full_name "$GITHUB_EVENT_PATH")
IS_FORK=$(jq --raw-output .pull_request.head.repo.fork "$GITHUB_EVENT_PATH")
if [[ "$IS_FORK" == "true" ]]; then
echo "This PR is created from a fork."
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" \
-X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO_FULL_NAME/issues/$PR_NUMBER/labels" \
-d '{"labels": ["external-contribution"]}')
if [[ $HTTP_STATUS -ge 300 ]]; then
echo "Failed to add label to PR, exiting."
exit 1
fi
else
echo "This PR is not created from a fork."
fi

0 comments on commit d42f707

Please sign in to comment.