-
Notifications
You must be signed in to change notification settings - Fork 3
134 lines (128 loc) · 4.33 KB
/
test-and-deploy.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
name: Test and deploy
on:
push:
branches:
- main
tags:
- v*
pull_request: {}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dev: ['--dev','']
env:
DEVFLAG: ${{ matrix.dev }}
steps:
- name: Print Docker Compose version
run: |
docker --version
docker-compose --version
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Run thunorbld.py init/testinit
run: |
if [[ $DEVFLAG == "--dev" ]]; then python thunorbld.py init; fi
if [[ $DEVFLAG == "" ]]; then python thunorbld.py testinit; fi
- name: Test suite
run: python thunorbld.py $DEVFLAG test
- name: Upload coverage
if: ${{ matrix.dev == '--dev' }}
run: codecov
deploy:
# needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Set release or dev mode
id: release_mode
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
echo "::set-output name=qs_branch::dev"
else
echo "::set-output name=qs_branch::main"
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Checkout Thunor Web
uses: actions/checkout@v2
with:
submodules: true
- name: Checkout Quickstart Repo
uses: actions/checkout@v2
with:
repository: alubbock/thunor-web-quickstart
ref: ${{ steps.release_mode.outputs.qs_branch }}
token: ${{ secrets.API_TOKEN_GITHUB }}
path: thunor-web-quickstart
- name: Build containers
run: python thunorbld.py --use-buildx build
- name: Update and push quickstart repo
run: |
set -e
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
GITHUB_TAG=${GITHUB_REF/refs\/tags\//}
echo "GitHub Tag: $GITHUB_TAG"
fi
echo "$DOCKERHUB_TOKEN" | docker login -u alubbock --password-stdin
cd thunor-web-quickstart
cp ../thunorctl.py .
cp ../docker-compose.services.yml .
cp ../docker-compose.certbot.yml .
rm -rf config-examples
cp -r ../config-examples .
if [ -z "$GITHUB_TAG" ]; then
sed -i 's/thunorweb:latest/thunorweb:dev/' docker-compose.services.yml
echo "$GITHUB_SHA" > .release
else
sed -i "s/thunorweb:latest/thunorweb:$GITHUB_TAG/" docker-compose.services.yml
echo "$GITHUB_TAG" > .release
fi
echo "Contents of .release: $(cat .release)"
git add -A
git status
git config user.email "[email protected]"
git config user.name "GitHub Actions CI"
if [[ $GITHUB_TAG ]]; then
git commit -m "CI update: $GITHUB_TAG"
git tag "$GITHUB_TAG"
git push --tags
# Make another commit referencing "latest" at HEAD
sed -i "s/thunorweb:$GITHUB_TAG/thunorweb:latest/" docker-compose.services.yml
git add docker-compose.services.yml
fi
git commit -m "CI update: $GITHUB_SHA"
git push
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag and push dev image build
if: ${{ steps.release_mode.outputs.qs_branch == 'dev' }}
run: |
docker push alubbock/thunorweb:dev
- name: Tag and push live image build
if: ${{ steps.release_mode.outputs.qs_branch != 'dev' }}
run: |
docker tag alubbock/thunorweb:dev alubbock/thunorweb:latest
docker tag alubbock/thunorweb:dev alubbock/thunorweb:$GITHUB_TAG
docker push alubbock/thunorweb:$GITHUB_TAG
docker push alubbock/thunorweb:latest
env:
GITHUB_TAG: ${{ steps.release_mode.outputs.version }}
cleanup:
needs: deploy
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Delete build image artifact
uses: geekyeggo/delete-artifact@v1
with:
name: thunor-web-container