-
Notifications
You must be signed in to change notification settings - Fork 3
116 lines (96 loc) · 3.7 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
name: CI/CD
on:
push:
pull_request:
env:
AWS_REGION : "eu-west-1"
NODE_VERSION: 16.x
WORKING_DIRECTORY: mail-client
jobs:
test:
runs-on: ubuntu-22.04
env:
HOME: '.'
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
- name: Install hugo
run: sudo apt-get install hugo
- name: Test hugo
run: hugo -s src -d ../target
- uses: actions/setup-node@v2
with:
node-version: '16.x'
# disable caching since it causes problems on post Run:
# Post job cleanup.
# /opt/hostedtoolcache/node/12.22.9/x64/bin/npm config get cache
# /home/runner/work/software-website/software-website/.npm
# Error: Cache folder path is retrieved for npm but doesn't exist on disk: /home/runner/work/software-website/software-website/.npm
# cache: 'npm'
# cache-dependency-path: mail-client/package.json
- name: mail client
run : npm install
working-directory: mail-client
deploy-test:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/main'
needs: test
concurrency: deploy-test
env:
AWS_S3_BUCKET_NAME : 'it.bz.freesoftwarelab.test'
HUGO_BASEURL: 'https://freesoftwarelab.noi.testingmachine.eu/'
MAIL_CLIENT: 'https://mail.software.bz.it/'
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install hugo
run: sudo apt-get install hugo
- name: Configuration hugo
run: |
sed -i -e "s%https://example.com%${{env.MAIL_CLIENT}}%g" src/themes/free-software-lab/static/js/main.js
sed -i -e "s%https://example.com%${{env.HUGO_BASEURL}}%g" src/config.toml
- name: Build hugo
run: hugo -s src -d ../target
- name: Sync to S3 bucket
uses: noi-techpark/github-actions/aws-s3-bucket-sync@v2
with:
access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
region: ${{ env.AWS_REGION }}
s3-bucket-name: ${{ env.AWS_S3_BUCKET_NAME }}
folder: ./target
deploy-prod:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/prod'
needs: test
concurrency: deploy-prod
env:
AWS_S3_BUCKET_NAME : "it.bz.freesoftwarelab"
HUGO_BASEURL: 'https://freesoftwarelab.noi.bz.it/'
MAIL_CLIENT: 'https://mail.software.bz.it/'
SCRIPTS_HOST: 'https://scripts.opendatahub.com'
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install hugo
run: sudo apt-get install hugo
- name: Configuration hugo
run: |
sed -i -e "s%https://example.com%${{env.MAIL_CLIENT}}%g" src/themes/free-software-lab/static/js/main.js
sed -i -e "s%https://example.com%${{env.HUGO_BASEURL}}%g" src/config.toml
- name: Change scripts host to prod
run: |
sed -i -e "s%https://scripts.opendatahub.testingmachine.eu%${{env.SCRIPTS_HOST}}%g" src/themes/free-software-lab/layouts/partials/footer.html
sed -i -e "s%https://scripts.opendatahub.testingmachine.eu%${{env.SCRIPTS_HOST}}%g" src/themes/free-software-lab/layouts/partials/head.html
- name: Build hugo
run: hugo -s src -d ../target
- name: Sync to S3 bucket
uses: noi-techpark/github-actions/aws-s3-bucket-sync@v2
with:
access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
region: ${{ env.AWS_REGION }}
s3-bucket-name: ${{ env.AWS_S3_BUCKET_NAME }}
folder: ./target