-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (61 loc) · 2.31 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: "Netlify Preview Deploy"
# Runs on all new PR actions
on:
pull_request:
types: ["opened", "edited", "synchronize"]
push:
branches:
- main
release:
types: ["published"]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Necessary to grab the HEAD commit from the source branch when
# acting on a PR. Otherwise, `git log` will only contain the merge commit
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v1
with:
node-version: "16.x"
- name: Build
run: |
yarn install --pure-lockfile --non-interactive
yarn build
- name: Create Deploy Message
run: |
# Grab branch path
FULL_PATH_REF="${{ github.event.pull_request.head.ref || github.ref }}"
# Strip "refs/heads/" from the start
REF=${FULL_PATH_REF#refs\/heads\/}
# Set it in env
echo "REF=$REF" >> $GITHUB_ENV
# Get the short form of the SHA
SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.sha }})
# Set it in env
echo "SHA=$SHA" >> $GITHUB_ENV
# Yank the commit message from the log, using the SHA
COMMIT_MSG=$(git log -n 1 --format=%s $SHA)
# Set it in env
echo "COMMIT_MSG=$COMMIT_MSG" >> $GITHUB_ENV
# use the PR title or the commit message
DEPLOY_MESSAGE="${{ github.event.pull_request.title || env.COMMIT_MSG }}"
# Set it in env
echo "DEPLOY_MESSAGE=$DEPLOY_MESSAGE" >> $GITHUB_ENV
# Sets the branch name as environment variable
- name: "Deploy"
uses: nwtgck/actions-netlify@v1.2
with:
alias: deploy-preview-${{ github.head_ref }}-${{ env.SHA }}
deploy-message: "${{ env.REF }}@${{ env.SHA }}: ${{ env.DEPLOY_MESSAGE }} (${{ github.workflow }} workflow)"
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-commit-comment: true
enable-pull-request-comment: true
production-branch: "main"
publish-dir: "_site_deploy"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}