-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.01 KB
/
deploy-pull-request.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
name: Deploy Pull Request
on: [pull_request, workflow_dispatch]
jobs:
deploy:
name: 🛺 Deploy Pull Request
runs-on: ubuntu-latest
steps:
- name: 🛂 Extract branch name
shell: bash
run: |
HEAD_REF=$(printf "%q" "${{ github.event.pull_request.head.ref }}")
HEAD_REF=${HEAD_REF/\//-}
echo "Sanitized branch name is $HEAD_REF"
if [[ -z "$GITHUB_OUTPUT" ]]; then
echo "::set-output name=branch::$(eval printf "%s" "$HEAD_REF")"
else
echo "branch=$(eval printf "%s" "$HEAD_REF")" >> "$GITHUB_OUTPUT"
fi
id: extract_branch
- name: ⚙️ Checkout
uses: actions/checkout@v3
- name: 🐚 Cache
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
- name: 🛠 Build
run: |
npm ci
HUGO_BASEURL="/design-system/${{ steps.extract_branch.outputs.branch }}/" npm run build
- name: 🌮 Keep dist directory
uses: actions/upload-artifact@v3
with:
name: dist-${{ steps.extract_branch.outputs.branch }}
path: dist/
- name: 📂 SFTP Deploy
uses: wlixcc/[email protected]
with:
username: ${{ secrets.USER }}
server: ${{ secrets.SERVER }}
port: 22
ssh_private_key: ${{ secrets.SSH_KEY }}
local_path: ./dist/*
remote_path: ./${{ steps.extract_branch.outputs.branch }}/
# sftp_only: # optional
# sftpArgs: # optional
# delete_remote_files: # optional
- name: 💬 Leave a message
uses: mshick/add-pr-comment@v1
with:
message: |
## 🛺 Branch preview has been deployed!
👉 <https://www.paris-web.fr/design-system/${{ steps.extract_branch.outputs.branch }}/index.html>
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: false