-
Notifications
You must be signed in to change notification settings - Fork 4
93 lines (91 loc) · 2.97 KB
/
build.yaml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
name: Build website
on:
push: {branches: [ main ]}
workflow_dispatch:
pull_request:
jobs:
determine_urls:
runs-on: ubuntu-latest
outputs:
siteurl: ${{ steps.get_siteurl.outputs.base_url }}
upload_dir: ${{ steps.get_siteurl.outputs.branch_dir }}
steps:
- name: Obtain pull-request number from event
id: get_siteurl
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
pull_dir="/_pr-${pull_number}"
echo "base_url=https://dev.chaos.jetzt${pull_dir}" >> $GITHUB_OUTPUT
echo "branch_dir=${pull_dir}" >> $GITHUB_OUTPUT
else
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
branch_name=${GITHUB_REF/refs\/heads/}
branch_dir="/${branch_name/\//_}"
echo "branch_dir=${branch_dir}" >> $GITHUB_OUTPUT
echo "base_url=https://dev.chaos.jetzt/${branch_dir}" >> $GITHUB_OUTPUT
else
echo "base_url=https://chaos.jetzt" >> $GITHUB_OUTPUT
echo "branch_dir=" >> $GITHUB_OUTPUT
fi
fi
build:
runs-on: ubuntu-latest
needs: [ determine_urls ]
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3'
cache: 'pip'
cache-dependency-path: requirements.txt
- run: pip install -r requirements.txt
- name: make publish
env:
SITEURL: ${{ needs.determine_urls.outputs.siteurl }}
run: make publish PELICANOPTS="-e SITEURL='\"$SITEURL\"'"
- uses: actions/upload-artifact@v2
with:
name: website_pelican-build
path: ./public
deploy_production:
runs-on: ubuntu-latest
needs: [ build ]
if: github.ref == 'refs/heads/main'
environment:
name: production
url: ${{ needs.determine_urls.outputs.siteurl }}
steps:
- uses: actions/download-artifact@v2
with:
name: website_pelican-build
- name: deploy
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: .
remote_host: chaos.jetzt
remote_user: web-deploy
remote_key: ${{ secrets.DEPLOY_KEY }}
deploy_dev:
runs-on: ubuntu-latest
needs: [ build, determine_urls ]
if: github.ref != 'refs/heads/main'
environment:
name: development
url: ${{ needs.determine_urls.outputs.siteurl }}
steps:
- uses: actions/download-artifact@v2
with:
name: website_pelican-build
- name: deploy
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: ${{ needs.determine_urls.outputs.upload_dir }}
remote_host: dev.chaos.jetzt
remote_user: web-deploy
remote_key: ${{ secrets.DEPLOY_KEY }}