-
Notifications
You must be signed in to change notification settings - Fork 47
58 lines (51 loc) · 1.79 KB
/
publish-site-to-netlify.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
54
55
56
57
58
name: Publish Site to Netlify
on:
push:
pull_request:
workflow_dispatch:
inputs:
publish_site:
type: boolean
description: 'Publish To Netlify'
default: false
jobs:
publish-to-netlify:
runs-on: ubuntu-latest
environment:
name: netlify
url: ${{ steps.netlify-status.outputs.NETLIFY_DEPLOY_URL }}
steps:
- name: Download Generated Site Artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: download
- name: Unpack Generated Site
run: |
mkdir -p public
tar -x -C public -v -f download/artifact.tar
- name: Cache Netlify CLI
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-netlify-cli-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-netlify-cli
- name: Deploy to Netlify
if: github.event.inputs.publish_site
uses: South-Paw/action-netlify-cli@v2
id: netlify
with:
args: deploy --dir ./public --message 'draft [${{ github.sha }}]' --json
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Get Netlify Preview URL
if: github.event.inputs.publish_site
id: netlify-status
run: |
echo "NETLIFY_DEPLOY_URL=${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}" >> $GITHUB_OUTPUT
echo "The URL where the logs from the deployment can be found"
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).logs }}"
echo ""
echo "the URL of the draft site that Netlify provides"
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}/"