Update PR-Demo-Comment.yml

This commit is contained in:
Anthony Stirling 2024-11-17 16:17:44 +00:00 committed by GitHub
parent e1b3cc736c
commit c43af24ffe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,10 +7,13 @@ on:
jobs: jobs:
check-comment: check-comment:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Only run on PR comments that contain @deployPR from authorized users
if: | if: |
github.event.issue.pull_request && github.event.issue.pull_request &&
contains(github.event.comment.body, 'prdeploy') && (
contains(github.event.comment.body, 'prdeploy') ||
contains(github.event.comment.body, 'deploypr')
)
&&
( (
github.event.comment.user.login == 'frooodle' || github.event.comment.user.login == 'frooodle' ||
github.event.comment.user.login == 'sf298' || github.event.comment.user.login == 'sf298' ||
@ -21,7 +24,8 @@ jobs:
) )
outputs: outputs:
pr_number: ${{ steps.get-pr.outputs.pr_number }} pr_number: ${{ steps.get-pr.outputs.pr_number }}
pr_branch: ${{ steps.get-pr-branch.outputs.result }} pr_repository: ${{ steps.get-pr-info.outputs.repository }}
pr_ref: ${{ steps.get-pr-info.outputs.ref }}
steps: steps:
- name: Get PR data - name: Get PR data
@ -33,9 +37,9 @@ jobs:
console.log(`PR Number: ${prNumber}`); console.log(`PR Number: ${prNumber}`);
core.setOutput('pr_number', prNumber); core.setOutput('pr_number', prNumber);
- name: Get PR branch - name: Get PR repository and ref
id: get-pr-info
uses: actions/github-script@v7 uses: actions/github-script@v7
id: get-pr-branch
with: with:
script: | script: |
const { owner, repo } = context.repo; const { owner, repo } = context.repo;
@ -47,16 +51,26 @@ jobs:
pull_number: prNumber, pull_number: prNumber,
}); });
return pr.head.ref; // For forks, use the full repository name, for internal PRs use the current repo
const repository = pr.head.repo.fork ? pr.head.repo.full_name : `${owner}/${repo}`;
console.log(`PR Repository: ${repository}`);
console.log(`PR Branch: ${pr.head.ref}`);
core.setOutput('repository', repository);
core.setOutput('ref', pr.head.ref);
deploy-pr: deploy-pr:
needs: check-comment needs: check-comment
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - name: Checkout PR
uses: actions/checkout@v4
with: with:
ref: ${{ needs.check-comment.outputs.pr_branch }} repository: ${{ needs.check-comment.outputs.pr_repository }}
ref: ${{ needs.check-comment.outputs.pr_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v4 uses: actions/setup-java@v4