-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (42 loc) · 1.41 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Build and Deploy to Netlify
on: [ push, workflow_dispatch ]
env:
BRANCH_NAME: ${{ github.ref_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create .env File
run: echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Netlify
run: pnpm install netlify-cli -g
- name: Install Dependencies
run: pnpm i --frozen-lockfile
- name: Build Application
run: pnpm run build
- name: Deploy to Netlify
id: netlify_deploy
run: |
prod_flag=""
if [ "$BRANCH_NAME" = "main" ]; then prod_flag="--prod"; fi
commit_message=$(git log -1 --pretty=%B) # Get the latest commit message
netlify deploy \
--site ${{ secrets.NETLIFY_SITE_ID }} \
--auth ${{ secrets.NETLIFY_API_TOKEN }} \
$prod_flag \
--message "$commit_message" \
--json \
> deploy_output.json
- name: Generate URL Preview
id: url_preview
if: ${{ env.BRANCH_NAME != 'main' }}
run: |
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"