Skip to content

Commit 7697ad6

Browse files
committed
add PR deploy preview
1 parent 6fc086c commit 7697ad6

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/cd_PR.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Pull Request build+deploy
2+
3+
on:
4+
pull_request:
5+
types: ['opened', 'edited', 'synchronize']
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
deploy:
11+
environment: branch-deploy
12+
name: Build and deploy
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
23+
24+
- name: Set up Docker
25+
uses: docker/setup-docker-action@v4
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: 'pnpm'
32+
33+
- name: Setup deployment
34+
uses: bobheadxi/deployments@v1
35+
id: deployment
36+
with:
37+
step: start
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
env: branch-deploy-${{ github.head_ref }}
40+
ref: ${{ github.head_ref }}
41+
42+
- name: Install dependencies
43+
run: ./setup.sh
44+
45+
- name: Deploy to Netlify
46+
uses: nwtgck/[email protected]
47+
with:
48+
publish-dir: './next'
49+
production-branch: main
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
deploy-message: "Deploy from GitHub Actions"
52+
enable-pull-request-comment: false
53+
enable-commit-comment: true
54+
overwrites-pull-request-comment: true
55+
alias: deploy-preview-${{ github.event.number }}-100xdevs
56+
env:
57+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
58+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
59+
timeout-minutes: 1
60+
61+
- name: Update deployment status
62+
uses: bobheadxi/deployments@v1
63+
if: always()
64+
with:
65+
step: finish
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
status: ${{ job.status }}
68+
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
69+
logs: ${{ steps.deploy-netlify.outputs.netlify_logs_url }}
70+
env_url: ${{ steps.deploy-netlify.outputs.netlify_preview_url }}

0 commit comments

Comments
 (0)