Skip to content

Commit

Permalink
Update Jenkins job to require maintainer trigger (#1238)
Browse files Browse the repository at this point in the history
* Update Jenkins job to validate maintainer

Signed-off-by: Tanner Lewis <[email protected]>
  • Loading branch information
lewijacn authored Jan 17, 2025
1 parent 4d369c1 commit 3f0209e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/full_pr_e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ jobs:
full-es68-e2e-aws-test:
runs-on: ubuntu-latest
steps:
- name: Check Github Actor is a Maintainer
id: check-maintainer
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
run: |
echo "Checking if $GITHUB_ACTOR is a maintainer..."
# Query the API to get the actor's permissions
permission=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"${{ github.api_url }}/repos/${{ github.repository }}/collaborators/${GITHUB_ACTOR}/permission" \
| jq -r '.permission')
echo "Actor permissions: $permission"
echo "actor_permission=$permission" >> $GITHUB_ENV
# Fail if the actor is not a maintainer
if [ "$permission" != "admin" ] && [ "$permission" != "write" ]; then
echo "::error::This workflow can only be triggered by a maintainer."
exit 1
fi
- name: Sanitize branch and repo names
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref || github.ref_name }}
Expand All @@ -31,6 +53,7 @@ jobs:
echo "branch_name=$clean_branch_name" >> $GITHUB_OUTPUT
echo "pr_repo_url=$clean_repo_url" >> $GITHUB_OUTPUT
- name: Jenkins Job Trigger and Monitor
if: env.actor_permission == 'admin' || env.actor_permission == 'write'
uses: lewijacn/[email protected]
with:
jenkins_url: "https://migrations.ci.opensearch.org"
Expand Down

0 comments on commit 3f0209e

Please sign in to comment.