mirror of
https://github.com/CorentinTh/enclosed.git
synced 2026-01-09 07:44:26 +08:00
chore(cd): preview app for forks PRs (#169)
This commit is contained in:
parent
6936892447
commit
0a01794ed8
8
.github/workflows/cd-app-prod.yaml
vendored
8
.github/workflows/cd-app-prod.yaml
vendored
@ -1,10 +1,12 @@
|
||||
name: CD - Production
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish-app:
|
||||
publish-app-prod:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
@ -38,7 +40,7 @@ jobs:
|
||||
branch: main
|
||||
wranglerVersion: '3'
|
||||
|
||||
publish-docs:
|
||||
publish-docs-prod:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
@ -56,7 +58,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: pnpm i
|
||||
|
||||
- name: Build the app
|
||||
- name: Build the docs
|
||||
run: pnpm -F @enclosed/docs build
|
||||
|
||||
- name: Publish to Cloudflare Pages
|
||||
|
||||
59
.github/workflows/cd-preview-build.yaml
vendored
Normal file
59
.github/workflows/cd-preview-build.yaml
vendored
Normal file
@ -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
|
||||
64
.github/workflows/cd-preview-deploy.yaml
vendored
Normal file
64
.github/workflows/cd-preview-deploy.yaml
vendored
Normal file
@ -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'
|
||||
Loading…
x
Reference in New Issue
Block a user