-
-
Notifications
You must be signed in to change notification settings - Fork 2
75 lines (73 loc) · 2.89 KB
/
deploy-preview.yaml
File metadata and controls
75 lines (73 loc) · 2.89 KB
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
# prettier-ignore
on:
push:
branches:
- main
pull_request_target:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
destination:
description: "Define destination base path"
required: true
default: "manual_run"
name: Site deploy preview
jobs:
build:
runs-on: ubuntu-latest
if: |
github.event_name != 'pull_request_target' ||
contains('MEMBER OWNER COLLABORATOR', github.event.pull_request.author_association)
permissions:
pull-requests: write
contents: read
steps:
- name: update PR
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Started attempt to build a new deploy preview for PR ${{ github.event.pull_request.number }}.
comment_tag: pr_published
- name: Checkout your repository using git
uses: actions/checkout@v3
with:
ref:
${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.sha || github.ref }}
- name: Install, build, and upload your site output
uses: withastro/action@v3
- run: ls -la
deploy-website:
runs-on: ubuntu-latest
if: |
github.event_name != 'pull_request_target' ||
contains('MEMBER OWNER COLLABORATOR', github.event.pull_request.author_association)
permissions:
pull-requests: write
contents: read
needs: build
steps:
- uses: actions/download-artifact@v4
with:
name: github-pages
- run: ls -la
- run: mkdir dist/
- run: tar -xvf artifact.tar -C dist/
- run: ls -la
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ARGS: "-rlgoDzvc -i --delete"
SOURCE: "dist/"
REMOTE_HOST: ${{ vars.REMOTE_HOST }}
REMOTE_USER: ${{ vars.REMOTE_USER }}
TARGET: ${{ vars.REMOTE_TARGET }}${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.event_name == 'push' && 'main' || github.event.inputs.destination}}
- name: update PR
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Created a new deploy preview for PR ${{ github.event.pull_request.number }}. [See preview](http://community-at-preview.fujocoded.dev/${{ github.event.pull_request.number }}/).
comment_tag: pr_published