-
Notifications
You must be signed in to change notification settings - Fork 10
69 lines (58 loc) · 2.09 KB
/
ci_cd.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
name: CI/CD
on:
push:
branches:
- main
pull_request:
# only allow one run per deploy target at once
concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
# cancel previous jobs as we are only interested in the newest
cancel-in-progress: true
jobs:
build:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node
id: node
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install dependencies
run: yarn install
- name: Run antora
run: |
yarn build
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: determine target path
run: |
echo "GITHUB_REF is $GITHUB_REF";
echo "PR number is ${{ github.event.number }}";
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
TARGET_PATH=
else
TARGET_PATH=_branches/pr/${{ github.event.number }}
fi
echo "target_path=/var/www/web25462234/html/docs.my-agrirouter.com/$TARGET_PATH" >> $GITHUB_ENV;
echo "target_url=https://docs.my-agrirouter.com/$TARGET_PATH" >> $GITHUB_ENV;
grep target_path $GITHUB_ENV;
grep target_url $GITHUB_ENV;
# very unelegant, but hoster does not support SSH key authentication :-/
- name: Rsync to Webspace
run: |
sshpass -p ${{secrets.SSH_PASSWORD}} ssh ${{secrets.SSH_USERNAME}}@${{secrets.SSH_HOSTNAME}} "mkdir -p ${{ env.target_path }}";
sshpass -p ${{secrets.SSH_PASSWORD}} rsync -av --exclude _branches --delete build/site/ ${{secrets.SSH_USERNAME}}@${{secrets.SSH_HOSTNAME}}:${{ env.target_path }}
- uses: mshick/add-pr-comment@v1
with:
message: |
The content of this PR can be reviewed at
🌏 ${{ env.target_url }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login:
allow-repeats: false