Skip to content

Commit

Permalink
fix: pull requests workflow permissions (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol authored Feb 14, 2025
1 parent faf589e commit de9e95f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/external-prs-handle-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: external-prs-handle-comment
env:
PR_TOOLS_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PR_TOOLS_GITHUB_APP_PRIVATE_KEY }}
PR_TOOLS_GITHUB_APP_ID: ${{ secrets.PR_TOOLS_GITHUB_APP_ID }}
PR_TOOLS_ADMIN_TEAM_NAME: ${{ secrets.PR_TOOLS_ADMIN_TEAM_NAME }}

on:
issue_comment:
Expand All @@ -17,7 +18,7 @@ jobs:
runs-on: ubuntu-latest

# This job only runs for pull request comments
if: github.event.issue.pull_request && contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.comment.author_association)
if: github.event.issue.pull_request
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -29,10 +30,16 @@ jobs:
- name: Setup external pr tools
uses: ./main/.github/workflows/setup-external-pr-tools

- name: Check if the user is an admin
id: prs_permissions
run: |
cd ./oso/ops/external-prs && pnpm tools common is-repo-admin ${{ github.event.pull_request.user.login }} --output-file $GITHUB_OUTPUT
- name: Parse the comment to see if it's a deploy comment
id: parse_comment
run: |
cd ./oso/ops/external-prs && pnpm tools ossd parse-comment --repo ${{ github.repository }} ${{ github.event.comment.id }} $GITHUB_OUTPUT
if: ${{ steps.prs_permissions.outputs.is_admin == '1' }}

- name: Login to google
uses: "google-github-actions/auth@v2"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/validate-pr-owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TOOLS_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PR_TOOLS_GITHUB_APP_PRIVATE_KEY }}
PR_TOOLS_GITHUB_APP_ID: ${{ secrets.PR_TOOLS_GITHUB_APP_ID }}
PR_TOOLS_ADMIN_TEAM_NAME: ${{ secrets.PR_TOOLS_ADMIN_TEAM_NAME }}

PR_TOOLS_REPO: ${{ github.repository }}

Expand Down Expand Up @@ -41,12 +42,17 @@ jobs:
cd ./oso/ops/external-prs &&
pnpm tools initialize-check ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.user.login }} "validate"
- name: Check if the user is an admin
id: prs_permissions
run: |
cd ./oso/ops/external-prs && pnpm tools common is-repo-admin ${{ github.event.pull_request.user.login }} --output-file $GITHUB_OUTPUT
- name: Login to google
uses: "google-github-actions/auth@v2"
with:
credentials_json: "${{ secrets.GOOGLE_BQ_ADMIN_CREDENTIALS_JSON }}"
create_credentials_file: true
if: ${{ contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR" ]'), github.event.pull_request.author_association) }}
if: ${{ steps.prs_permissions.outputs.is_admin == '1' }}

- name: Run validation
uses: ./main/.github/workflows/validate
Expand All @@ -61,4 +67,4 @@ jobs:
arbitrum_rpc_url: ${{ secrets.PR_TOOLS_ARBITRUM_RPC_URL }}
base_rpc_url: ${{ secrets.PR_TOOLS_BASE_RPC_URL }}
optimism_rpc_url: ${{ secrets.PR_TOOLS_OPTIMISM_RPC_URL }}
if: ${{ contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR" ]'), github.event.pull_request.author_association) }}
if: ${{ steps.prs_permissions.outputs.is_admin == '1' }}

0 comments on commit de9e95f

Please sign in to comment.