-
-
Notifications
You must be signed in to change notification settings - Fork 152
Adding cloudflare preview builds #822
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||||
name: 'Preview Deployment' | ||||||||||||||
on: | ||||||||||||||
pull_request_target: | ||||||||||||||
branches: | ||||||||||||||
- master | ||||||||||||||
|
||||||||||||||
jobs: | ||||||||||||||
deploy: | ||||||||||||||
permissions: | ||||||||||||||
actions: read | ||||||||||||||
contents: read | ||||||||||||||
deployments: write | ||||||||||||||
pull-requests: write | ||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||
timeout-minutes: 5 | ||||||||||||||
steps: | ||||||||||||||
- name: Checkout code | ||||||||||||||
uses: actions/checkout@v4 | ||||||||||||||
|
||||||||||||||
Comment on lines
+17
to
+19
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. Checkout PR head commit on pull_request_target - - uses: actions/checkout@v4
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.head.sha }} 📝 Committable suggestion
Suggested change
|
||||||||||||||
- name: Cache node_modules | ||||||||||||||
uses: actions/cache@v4 | ||||||||||||||
with: | ||||||||||||||
path: node_modules/ | ||||||||||||||
key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | ||||||||||||||
|
||||||||||||||
- name: Install node.js | ||||||||||||||
uses: actions/setup-node@v4 | ||||||||||||||
with: | ||||||||||||||
node-version-file: '.nvmrc' | ||||||||||||||
|
||||||||||||||
- run: npm install yarn -g | ||||||||||||||
- run: yarn install | ||||||||||||||
- run: yarn build | ||||||||||||||
|
||||||||||||||
- name: Deploy to Cloudflare | ||||||||||||||
id: deploy | ||||||||||||||
uses: cloudflare/wrangler-action@v3 | ||||||||||||||
with: | ||||||||||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||||||||||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||||||||||||||
command: pages deploy src/dist --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch ${{ github.head_ref }} --commit-dirty=true | ||||||||||||||
|
||||||||||||||
- name: Add deployment comment | ||||||||||||||
uses: thollander/actions-comment-pull-request@v3 | ||||||||||||||
with: | ||||||||||||||
message: | | ||||||||||||||
Preview URL: ${{ steps.deploy.outputs.deployment-url }} | ||||||||||||||
reactions: eyes, rocket | ||||||||||||||
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.
Suggested change
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. @blckmn - this was requested by @nerdCopter 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. Yes this updates the single comment (recreation mode) issue. I'm keeping the emojis though :) |
||||||||||||||
comment-tag: 'Preview URL' | ||||||||||||||
mode: recreate |
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.
🛠️ Refactor suggestion
Add
issues: write
permission for PR commentsTo allow the comment action to post deployment URLs on the pull request, include the
issues: write
permission underpermissions
.permissions: actions: read contents: read deployments: write + issues: write pull-requests: write
📝 Committable suggestion