-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f68806
commit d988b90
Showing
2 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build Preview Deployment | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
# cancel in-progress runs on new commits to same PR (github.event.number) | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-preview: | ||
runs-on: ubuntu-latest | ||
name: Build Preview Site and Upload Build Artifact | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.15.0 | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build dist folder | ||
run: npm run generate | ||
|
||
# Uploads the build directory as a workflow artifact | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: preview-build | ||
path: ./dist |
This file contains 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 |
---|---|---|
@@ -1,62 +1,39 @@ | ||
#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 #################### | ||
# | ||
# | ||
# | ||
# IF YOU DON'T KNOW WHAT YOU'RE DOING, YOU CAN EASILY LEAK SECRETS BY USING A | ||
# `pull_request_target` WORKFLOW INSTEAD OF `pull_request`! SERIOUSLY, DO NOT | ||
# BLINDLY COPY AND PASTE THIS FILE WITHOUT UNDERSTANDING THE FULL IMPLICATIONS | ||
# OF WHAT YOU'RE DOING! WE HAVE TESTED THIS FOR OUR OWN USE CASES, WHICH ARE | ||
# NOT NECESSARILY THE SAME AS YOURS! WHILE WE AREN'T EXPOSING ANY OF OUR SECRETS, | ||
# ONE COULD EASILY DO SO BY MODIFYING OR ADDING A STEP TO THIS WORKFLOW! | ||
# | ||
# | ||
# | ||
#################### 🚧 WARNING: READ THIS BEFORE USING THIS FILE 🚧 #################### | ||
|
||
name: Preview Deployment | ||
name: Upload Preview Deployment | ||
on: | ||
pull_request_target: | ||
workflow_run: | ||
workflows: [Build Preview Deployment] | ||
types: | ||
- completed | ||
|
||
# cancel in-progress runs on new commits to same PR (github.event.number) | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.number || github.sha }} | ||
cancel-in-progress: true | ||
permissions: | ||
actions: read | ||
deployments: write | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
deploy-preview: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
deployments: write | ||
runs-on: ubuntu-latest | ||
name: Deploy Preview to Cloudflare Pages | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.15.0' | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build dist folder | ||
run: npm run generate | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
name: Deploy Preview to Cloudflare Pages | ||
steps: | ||
# Downloads the build directory from the previous workflow | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
id: preview-build-artifact | ||
with: | ||
name: preview-build | ||
path: build | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Deploy to Cloudflare Pages | ||
id: cloudflare-pages-deploy | ||
uses: AdrianGonz97/refined-cf-pages-action@v1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
projectName: cvfy | ||
directory: ./dist | ||
deploymentName: Preview | ||
wranglerVersion: '3' | ||
- name: Deploy to Cloudflare Pages | ||
uses: AdrianGonz97/refined-cf-pages-action@v1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
projectName: cvfy | ||
deploymentName: Preview | ||
wranglerVersion: '3' | ||
directory: ${{ steps.preview-build-artifact.outputs.download-path }} |