-
Notifications
You must be signed in to change notification settings - Fork 11
fix(ci/deploy): run on contributors PR #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DarianM
wants to merge
2
commits into
main
Choose a base branch
from
ok-to-deploy-issue-comment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,37 +6,57 @@ on: | |
| pull_request: | ||
| branches: [main] | ||
| paths-ignore: ['**.md'] | ||
| pull_request_review: | ||
| types: [submitted] | ||
| branches: [main] | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
| issues: read | ||
| contents: read | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Deploy | ||
| check-permissions: | ||
| name: Check Permissions | ||
| runs-on: ubuntu-latest | ||
| if: | | ||
| github.event_name == 'push' || | ||
| github.event_name == 'pull_request' || | ||
| (github.event_name == 'issue_comment' && github.event.issue.pull_request) | ||
| outputs: | ||
| should-deploy: ${{ steps.check.outputs.should-deploy }} | ||
| pr-number: ${{ steps.check.outputs.pr-number }} | ||
| pr-head-sha: ${{ steps.check.outputs.pr-head-sha }} | ||
| pr-base-sha: ${{ steps.check.outputs.pr-base-sha }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Checkout base branch for security check | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| # Ensures we checkout the PR head commit for both pull_request and pull_request_review events | ||
| ref: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| # Fetches the full git history, both base and head SHAs are available | ||
| fetch-depth: 0 | ||
| fetch-depth: 1 | ||
|
Comment on lines
37
to
+38
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use defaults? |
||
|
|
||
| - name: Check deployment permissions | ||
| id: deploy-check | ||
| id: check | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const script = await import('${{ github.workspace }}/.github/scripts/check-deploy-permissions.ts'); | ||
| await script.default({ core, context }); | ||
|
|
||
| await script.default({ core, context, github }); | ||
|
|
||
| deploy: | ||
| name: Deploy | ||
| runs-on: ubuntu-latest | ||
| needs: check-permissions | ||
| if: needs.check-permissions.outputs.should-deploy == 'true' | ||
| steps: | ||
| # warning: untrusted code, checkout the PR head only after auth check passed | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ needs.check-permissions.outputs.pr-head-sha || github.event.pull_request.head.sha || github.sha }} | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: ./.github/workflows/setup | ||
|
|
||
| - name: Install wrangler globally | ||
|
|
@@ -48,7 +68,7 @@ jobs: | |
|
|
||
| # https://github.com/dorny/paths-filter/issues/232 | ||
| - uses: dorny/paths-filter@v3 | ||
| if: github.event_name != 'pull_request_review' | ||
| if: github.event_name != 'issue_comment' | ||
| id: changes | ||
| with: | ||
| filters: | | ||
|
|
@@ -70,13 +90,13 @@ jobs: | |
| - *cdn | ||
| - 'frontend/**' | ||
|
|
||
| - name: Detect changes for review-triggered deployment | ||
| if: github.event_name == 'pull_request_review' | ||
| - name: Detect changes for issue_comment deployment | ||
| if: github.event_name == 'issue_comment' | ||
| id: changes-review | ||
| run: | | ||
| # Get the PR base and head SHAs | ||
| BASE_SHA=${{ github.event.pull_request.base.sha }} | ||
| HEAD_SHA=${{ github.event.pull_request.head.sha }} | ||
| # Get the PR base and head SHAs from the check-permissions job outputs | ||
| BASE_SHA=${{ needs.check-permissions.outputs.pr-base-sha }} | ||
| HEAD_SHA=${{ needs.check-permissions.outputs.pr-head-sha }} | ||
|
|
||
| # Get list of changed files in the PR | ||
| CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA) | ||
|
|
@@ -135,7 +155,7 @@ jobs: | |
| name: 'api' | ||
| changed: ${{ steps.changes.outputs.api || steps.changes-review.outputs.api }} | ||
| mode: ${{ steps.deploy-mode.outputs.mode }} | ||
| skip-deploy: ${{ steps.deploy-check.outputs.should-deploy == 'false' }} | ||
| skip-deploy: 'false' | ||
| BUILD_AWS_PREFIX: ${{ vars.AWS_PREFIX }} | ||
| stagingUrl: ${{ vars.API_STAGING_URL }} | ||
| productionUrl: ${{ vars.API_PRODUCTION_URL }} | ||
|
|
@@ -149,7 +169,7 @@ jobs: | |
| name: 'cdn' | ||
| changed: ${{ steps.changes.outputs.cdn || steps.changes-review.outputs.cdn }} | ||
| mode: ${{ steps.deploy-mode.outputs.mode }} | ||
| skip-deploy: ${{ steps.deploy-check.outputs.should-deploy == 'false' }} | ||
| skip-deploy: 'false' | ||
| build: 'pnpm -C cdn run build' | ||
| BUILD_API_URL: ${{ steps.api.outputs.url }} | ||
| BUILD_AWS_PREFIX: ${{ vars.AWS_PREFIX }} | ||
|
|
@@ -165,7 +185,7 @@ jobs: | |
| name: 'frontend' | ||
| changed: ${{ steps.changes.outputs.frontend || steps.changes-review.outputs.frontend }} | ||
| mode: ${{ steps.deploy-mode.outputs.mode }} | ||
| skip-deploy: ${{ steps.deploy-check.outputs.should-deploy == 'false' }} | ||
| skip-deploy: 'false' | ||
| build: 'pnpm -C frontend run build' | ||
| BUILD_API_URL: ${{ steps.api.outputs.url }} | ||
| BUILD_CDN_URL: ${{ steps.cdn.outputs.url }} | ||
|
|
@@ -222,11 +242,11 @@ jobs: | |
| } | ||
|
|
||
| - name: Create deploy comment | ||
| if: github.event_name == 'pull_request' | ||
| if: github.event_name == 'pull_request' || github.event_name == 'issue_comment' | ||
| continue-on-error: true | ||
| uses: edumserrano/find-create-or-update-comment@v3 | ||
| with: | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| issue-number: ${{ github.event.pull_request.number || needs.check-permissions.outputs.pr-number }} | ||
| body-includes: '<!-- worker-deploy-summary -->' | ||
| comment-author: 'github-actions[bot]' | ||
| body: | | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
isAllowedAuthorsomehow? Maybe with a different API call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fetch the comment by ID, can get
author_associationhttps://api.github.com/repos/interledger/publisher-tools/issues/comments/3799339719