-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cd): preview app for forks PRs (#169)
- Loading branch information
1 parent
6936892
commit 0a01794
Showing
3 changed files
with
128 additions
and
3 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
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,59 @@ | ||
# Name used in ./cd-preview-deploy.yaml | ||
name: CD - Preview Build | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
build-app-preview: | ||
runs-on: ubuntu-latest | ||
name: Build app and upload build artifact | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
corepack: true | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm i | ||
|
||
- name: Build the app | ||
run: pnpm -F @enclosed/deploy-cloudflare build | ||
|
||
# Uploads the build directory as a workflow artifact | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: preview-app-build | ||
if-no-files-found: error | ||
path: packages/deploy-cloudflare/dist | ||
|
||
build-docs-preview: | ||
runs-on: ubuntu-latest | ||
name: Build docs and upload build artifact | ||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | ||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
corepack: true | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm i | ||
|
||
- name: Build the docs | ||
run: pnpm -F @enclosed/docs build | ||
|
||
# Uploads the build directory as a workflow artifact | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: preview-docs-build | ||
if-no-files-found: error | ||
path: packages/docs/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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CD - Preview Deploy | ||
|
||
on: | ||
workflow_run: | ||
workflows: [CD - Preview Build] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
actions: read | ||
deployments: write | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
deploy-app-preview: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
name: Deploy app preview | ||
steps: | ||
- name: Download app build artifact | ||
uses: actions/download-artifact@v4 | ||
id: preview-app-build-artifact | ||
with: | ||
name: preview-app-build | ||
path: build | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Deploy preview app 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: enclosed | ||
deploymentName: Preview | ||
directory: ${{ steps.preview-app-build-artifact.outputs.download-path }} | ||
wranglerVersion: '3' | ||
|
||
deploy-docs-preview: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
name: Deploy docs preview | ||
steps: | ||
- name: Download docs build artifact | ||
uses: actions/download-artifact@v4 | ||
id: preview-docs-build-artifact | ||
with: | ||
name: preview-docs-build | ||
path: build | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Deploy preview docs 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: enclosed-docs | ||
deploymentName: Preview | ||
directory: ${{ steps.preview-docs-build-artifact.outputs.download-path }} | ||
wranglerVersion: '3' |