-
Notifications
You must be signed in to change notification settings - Fork 13
132 lines (112 loc) · 3.37 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: "Build Site and Deploy"
on:
push:
branches: "release"
pull_request:
env:
GITHUB_PR_NUMBER: "${{github.event.number}}"
PREVIEW_PATH: "./preview"
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Install Nix
uses: cachix/install-nix-action@v12
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20201221_9fab14a/install
extra_nix_config: |
experimental-features = nix-command flakes
- name: Compile Document
run: nix run ./#compile
- name: Disable Jekyll rendering
run: touch build/site/.nojekyll
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: blog-build
path: ./build/site
deploy-preview:
name: Deploy Preview
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Start deployment
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: preview (#${{ env.GITHUB_PR_NUMBER }})
desc: Preview deployment of PR \#${{ env.GITHUB_PR_NUMBER }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Download Preview Repo
uses: actions/checkout@v2
with:
repository: ysndr/beta
ref: gh-pages
path: preview
- name: Untrack preview
run: rm -rf ./preview/.git
- name: Download Current Build
uses: actions/download-artifact@v2
with:
name: blog-build
path: current
- name: Apply Preview
run: |
export PR_PATH="$PREVIEW_PATH/$GITHUB_PR_NUMBER"
mkdir -p $PREVIEW_PATH
[ -d $PR_PATH ] && rm -r $PR_PATH
mv ./current $PR_PATH
- name: Deploy to GitHub
uses: crazy-max/ghaction-github-pages@v2
with:
repo: ysndr/beta
target_branch: gh-pages
build_dir: ./preview
committer: github-ci <notifications+ci-blog@ysndr.de>
keep_history: true;
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ steps.deployment.outputs.env }}
env_url: https://ysndr.de/beta/${{ env.GITHUB_PR_NUMBER }}
deploy-release:
name: Deploy Release
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Download Current Build
uses: actions/download-artifact@v2
with:
name: blog-build
path: release
- name: Deploy to GitHub
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: ./release
name: github-ci <notifications+ci-blog@ysndr.de>
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
always-run:
runs-on: ubuntu-latest
steps:
- name: Be friendly
run: |
echo "This is just here to prevent failure if the commit is not supposed to be build."
echo "Don't mind, have a joke :)"
echo "$(curl -Ss https://icanhazdadjoke.com/)"