-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) · 2.63 KB
/
ci.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
94
95
96
97
98
99
100
name: CI
on:
push:
branches:
- main
- staging
- develop
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
# Adds ability to run this workflow manually
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Manual run'
required: false
type: boolean
jobs:
CI:
if: github.repository == 'scilifelabdatacentre/serve'
runs-on: ubuntu-20.04
env:
working-directory: .
steps:
- name: Branch or tag that triggered the workflow run
run: |
echo "Running on branch ${GITHUB_REF##*/}"
echo "Running as UID: $UID, GID: $GID"
whoami
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare repository
run: |
echo "Running as UID: $UID, GID: $GID"
export GID=127
echo "Now running as UID: $UID, GID: $GID"
whoami
pwd
mv .env.template .env
sudo chgrp -R 127 media
sudo chmod -R g+rwx media
ls -al
sed -i 's/UID=1000/UID=1001/g' .env
sed -i 's/GID=1000/GID=127/g' .env
- name: Start serve
working-directory: ${{env.working-directory}}
id: setup
run: |
set -ex
echo "Deploying serve"
docker compose up -d --build
- name: Set Serve URL
working-directory: ${{env.working-directory}}
run: |
curl --version | head -n 1
STUDIO_URL=http://studio.127.0.0.1.nip.io:8080
echo "STUDIO_URL=$STUDIO_URL" >> $GITHUB_ENV
echo "The Serve URL is $STUDIO_URL"
- name: Check URL is up
uses: gerdemann/[email protected]
with:
url: ${{ env.STUDIO_URL }}
code: 200 # http status code
timeout: 120 # seconds
interval: 5 # seconds
continue-on-error: true
- name: Check if Serve is ready
working-directory: ${{env.working-directory}}
id: check_serve_up
run: |
echo "Checking response from STUDIO_URL: ${{ env.STUDIO_URL }}"
response=$(curl --write-out '%{http_code}' --silent --output /dev/null ${{ env.STUDIO_URL }})
if [[ "$response" -ne 200 ]] ; then echo "status $response" && sleep 30; else echo "serve is ready"; fi
- name: Run unit tests
working-directory: ${{env.working-directory}}
id: tests
run: |
docker compose run unit-tests