Skip to content

Commit

Permalink
Update PR-Demo-Comment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Frooodle authored Nov 17, 2024
1 parent e1b3cc7 commit c43af24
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/PR-Demo-Comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ on:
jobs:
check-comment:
runs-on: ubuntu-latest
# Only run on PR comments that contain @deployPR from authorized users
if: |
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 == 'sf298' ||
Expand All @@ -21,7 +24,8 @@ jobs:
)
outputs:
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:
- name: Get PR data
Expand All @@ -33,9 +37,9 @@ jobs:
console.log(`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
id: get-pr-branch
with:
script: |
const { owner, repo } = context.repo;
Expand All @@ -47,16 +51,26 @@ jobs:
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:
needs: check-comment
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout PR
uses: actions/checkout@v4
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
uses: actions/setup-java@v4
Expand Down

0 comments on commit c43af24

Please sign in to comment.