Skip to content

Commit 9508900

Browse files
deploy preview
1 parent 6af36d7 commit 9508900

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# prettier-ignore
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
workflow_dispatch:
9+
inputs:
10+
destination:
11+
description: "Define destination base path"
12+
required: true
13+
default: "manual_run"
14+
name: Site deploy preview
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
pull-requests: write
21+
contents: read
22+
steps:
23+
- name: update PR
24+
if: ${{ github.event_name == 'pull_request' }}
25+
uses: thollander/actions-comment-pull-request@v2
26+
with:
27+
message: |
28+
Started attempt to build a new deploy preview for PR ${{ github.event.pull_request.number }}.
29+
comment_tag: pr_published
30+
- name: Checkout your repository using git
31+
uses: actions/checkout@v3
32+
with:
33+
ref:
34+
${{ github.event_name == 'pull_request' &&
35+
github.event.pull_request.head.sha || github.ref }}
36+
- name: Install, build, and upload your site output
37+
uses: withastro/action@v3
38+
- run: ls -la
39+
40+
deploy-website:
41+
runs-on: ubuntu-latest
42+
permissions:
43+
pull-requests: write
44+
contents: read
45+
needs: build
46+
steps:
47+
- uses: actions/download-artifact@v4
48+
with:
49+
name: github-pages
50+
- run: ls -la
51+
- run: mkdir dist/
52+
- run: tar -xvf artifact.tar -C dist/
53+
- run: ls -la
54+
- name: Deploy to Server
55+
uses: easingthemes/ssh-deploy@main
56+
with:
57+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
58+
ARGS: "-rlgoDzvc -i --delete"
59+
SOURCE: "dist/"
60+
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
61+
REMOTE_USER: ${{ secrets.REMOTE_USER }}
62+
TARGET: ${{ secrets.REMOTE_TARGET }}${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.event_name == 'push' && 'main' || github.event.inputs.destination}}
63+
- name: update PR
64+
if: ${{ github.event_name == 'pull_request' }}
65+
uses: thollander/actions-comment-pull-request@v2
66+
with:
67+
message: |
68+
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 }}/).
69+
comment_tag: pr_published

0 commit comments

Comments
 (0)