-
Notifications
You must be signed in to change notification settings - Fork 63
59 lines (57 loc) · 2.27 KB
/
deploy-to-s3.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
name: Deploy To S3
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wrc
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# install font libraries
sudo apt-get update -qq && \
sudo apt-get install --no-install-recommends -y \
fonts-unfonts-core \
fonts-wqy-microhei \
fonts-ipafont \
lmodern \
libxrender1
# install wkhtmltopdf
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -O wkhtml.tar.xz && sudo tar -xf wkhtml.tar.xz --strip-components=1 -C /usr/local
- name: Build and deploy to S3
run: |
outputdir=/tmp/translations
languages=$(wrc-languages)
git_hash=$(git rev-parse --short "$GITHUB_SHA")
# Build all translations
for kind in html pdf; do
for l in $languages; do
lang_inputdir=./${l}
lang_outputdir=$outputdir/${l}
mkdir -p $lang_outputdir
echo "Generating ${kind} for language ${l}"
wrc --target=$kind -g $git_hash -l $l -o $lang_outputdir $lang_inputdir
# Update timestamp for semi-automatic computation of translations index
cp $lang_inputdir/metadata.json $lang_outputdir/
done
done
# Update version built
echo "$git_hash" > $outputdir/version
# Update timestamps for automatically determining which regulations are up to date
cp ./version-date $outputdir/
aws s3 sync $outputdir s3://wca-regulations/translations --acl public-read