-
Notifications
You must be signed in to change notification settings - Fork 34
167 lines (147 loc) · 5.65 KB
/
www.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build and publish awesomewm.org
on:
# Trigger on push to branche `master`.
push:
branches: [ master ]
# Trigger on pull request events for PRs that have `master` as their target branch
pull_request:
branches: [ master ]
# Allow running the workflow manually
workflow_dispatch:
defaults:
run:
# GitHub Actions adds `errexit` and `pipefail` by default, but we add `xtrace`
# to improve debugging some of the longer scripts.
shell: /bin/bash -o errexit -o pipefail -o xtrace {0}
jobs:
main:
runs-on: ubuntu-20.04
env:
BUILD_WEB: "/tmp/build-web"
steps:
# Create a cache invalidation key based on the current year + week.
# This way, packages will be checked for updates once every week.
- name: Get Date
id: get-date
run: echo "::set-output name=date::$(/bin/date -u "+%Y%W")"
- name: Cache apt packages
id: cache-apt
uses: actions/cache@v2
with:
path: /var/cache/apt/archives
# The trailing number serves as a version flag that can be incremented
# to invalidate the cache after changing the list of packages.
key: ${{ github.workflow }}-${{ runner.os }}-${{ steps.get-date.outputs.date }}-apt-3
- name: Download apt packages
if: steps.cache-apt.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install --download-only -y --no-install-recommends \
ikiwiki \
asciidoc \
imagemagick \
perlmagick \
luarocks \
cmake \
libxcb-cursor-dev \
libxcb-randr0-dev \
libxcb-xtest0-dev \
libxcb-xinerama0-dev \
libxcb-shape0-dev \
libxcb-util0-dev \
libxcb-keysyms1-dev \
libxcb-icccm4-dev \
libxcb-xrm-dev \
libxdg-basedir-dev \
libstartup-notification0-dev \
libxcb-xkb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
gir1.2-pango-1.0 \
xutils-dev \
libgirepository1.0-dev \
lua-discount
- name: Install downloaded packages
run: |
sudo dpkg -i /var/cache/apt/archives/*.deb
- name: Cache luarocks
id: cache-luarocks
uses: actions/cache@v2
with:
path: /tmp/luarocks
key: ${{ github.workflow }}-${{ runner.os }}-luarocks-3.5.0
- name: Install fresh Luarocks
if: steps.cache-luarocks.outputs.cache-hit != 'true'
run: |
wget -O /tmp/luarocks.tar.gz https://github.com/luarocks/luarocks/archive/v3.5.0.tar.gz
mkdir /tmp/luarocks
tar -xf /tmp/luarocks.tar.gz -C /tmp/luarocks --strip-components=1
cd /tmp/luarocks
./configure
make build
sudo make install
- name: Install cached Luarocks
if: steps.cache-luarocks.outputs.cache-hit == 'true'
run: |
cd /tmp/luarocks
sudo make install
- name: Install rocks
run: |
sudo -H luarocks install lgi
sudo -H luarocks install ldoc
- name: Install mdl
run: |
sudo gem install mdl -v 0.9.0
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Get Awesome website target repo
env:
APIDOC_TOKEN: ${{ secrets.AWESOME_ROBOT_TOKEN || github.token }}
run: |
set -e
git clone \
https://${APIDOC_TOKEN}@github.com/awesomeWM/awesomeWM.github.io \
"$BUILD_WEB" 2>&1 | sed "s/$APIDOC_TOKEN/APIDOC_TOKEN/g"
if [ "${{ github.event_name }}" != 'pull_request' ]; then
branch="${{ github.head_ref || github.ref_name }}"
else
branch="pr-${{ github.event.pull_request.number }}"
fi
if [ "$branch" != master ]; then
cd "$BUILD_WEB"
if ! git checkout -b "$branch" "origin/$branch"; then
git checkout -b "$branch"
fi
cd -
fi
- name: Build website
run: |
cd "${{ github.workspace }}"
PKG_CONFIG_PATH="$HOME/install/lib/pkgconfig" make build_for_gh_actions
mdl --git-recurse .
- name: Publish website
if: github.event_name != 'pull_request'
env:
APIDOC_TOKEN: ${{ secrets.AWESOME_ROBOT_TOKEN || github.token }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_AUTH_EMAIL: ${{ secrets.CLOUDFLARE_AUTH_EMAIL }}
CLOUDFLARE_AUTH_KEY: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
run: |
set -e
commit_hash=$(git rev-parse --short HEAD)
cd "$BUILD_WEB"
git config user.name "awesome-robot on GH Actions"
git config user.email "[email protected]"
git add --all .
NL=$'\n'
git commit -m "Update from GH Actions for awesome-www@${commit_hash}${NL}${NL}Commits: ${{ github.event.pull_request.commits_url }}${NL}Build URL: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
git --no-pager show --stat
git push origin "$(git symbolic-ref --quiet HEAD)" 2>&1 | sed "s/$APIDOC_TOKEN/APIDOC_TOKEN/g"
# Purge CloudFlare cache.
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \
-H "X-Auth-Email: $CLOUDFLARE_AUTH_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_AUTH_KEY" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
# vim: filetype=yaml:expandtab:shiftwidth=2:tabstop=2