-
Notifications
You must be signed in to change notification settings - Fork 79
180 lines (177 loc) · 7.48 KB
/
build.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
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build
on:
pull_request:
push:
workflow_dispatch:
jobs:
build_bases:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["latest", "stable", "legacy"]
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Set Humhub version
run: |
HUMHUB_VERSION="$(awk -e '$0 ~ /^([0-9\.]+) [0-9\.]+ ${{ matrix.version }}/ {print $1}' versions.txt)"
export HUMHUB_VERSION
echo "HUMHUB_VERSION=$HUMHUB_VERSION" >> "$GITHUB_ENV"
- name: Build and push docker image
run: |
docker build \
--build-arg HUMHUB_VERSION="${HUMHUB_VERSION}" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--target base \
-t "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-base" \
.
docker save "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-base" | gzip > build-${{ matrix.version }}.tar.gz
- name: Upload image archive
uses: actions/upload-artifact@v4.4.3
with:
name: build-${{ matrix.version }}
path: build-${{ matrix.version }}.tar.gz
build_variants:
needs: build_bases
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["latest", "stable", "legacy"]
target: ["allinone", "nginx", "phponly"]
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Set Humhub version
run: |
HUMHUB_VERSION=$(awk -e '$0 ~ /^([0-9\.]+) [0-9\.]+ ${{ matrix.version }}/ {print $1}' versions.txt)
export HUMHUB_VERSION
echo "HUMHUB_VERSION=$HUMHUB_VERSION" >> "$GITHUB_ENV"
- name: Download image archive
uses: actions/download-artifact@v4.1.7
with:
name: build-${{ matrix.version }}
- name: Build and push docker image
run: |
docker load --input build-${{ matrix.version }}.tar.gz
docker build \
--build-arg HUMHUB_VERSION="${HUMHUB_VERSION}" \
--build-arg VCS_REF="$(git rev-parse --short HEAD)" \
--target "humhub_${{ matrix.target }}" \
-t "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-${{ matrix.target }}" \
.
docker save "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-${{ matrix.target }}" | gzip > "build-${{ matrix.version }}-${{ matrix.target }}.tar.gz"
- name: Upload image archive
uses: actions/upload-artifact@v4.4.3
with:
name: build-${{ matrix.version }}-${{ matrix.target }}
path: build-${{ matrix.version }}-${{ matrix.target }}.tar.gz
test_aio:
needs: build_variants
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["latest", "stable", "legacy"]
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Set Humhub version
run: |
HUMHUB_VERSION=$(awk -e '$0 ~ /^([0-9\.]+) [0-9\.]+ ${{ matrix.version }}/ {print $1}' versions.txt)
export HUMHUB_VERSION
echo "HUMHUB_VERSION=$HUMHUB_VERSION" >> "$GITHUB_ENV"
- name: Download image archive
uses: actions/download-artifact@v4.1.7
with:
name: build-${{ matrix.version }}-allinone
- name: Load images
run: |
docker load --input build-${{ matrix.version }}-allinone.tar.gz
- name: replace image
run: sed -i "s/docker.io\/mriedmann\/humhub:latest/ghcr.io\/${GITHUB_REPOSITORY_OWNER}\/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-allinone/g" docker-compose.yml
- name: Spin up services
run: docker compose -f docker-compose.yml up -d
- name: Wait
run: sleep 60
- name: Check status
run: docker ps -a
- name: Logs
run: docker compose logs
- name: Test
run: curl http://localhost:8080/ -L --fail && curl http://localhost:8080/ -L --fail -s | grep 'Sign in</button>' -q
- name: Test Email
run: docker compose exec -T humhub php /var/www/localhost/htdocs/protected/yii test/email 'test@example.com' | grep 'Message successfully sent!' -q
test_prod:
needs: build_variants
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["latest", "stable", "legacy"]
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Set Humhub version
run: |
HUMHUB_VERSION=$(awk -e '$0 ~ /^([0-9\.]+) [0-9\.]+ ${{ matrix.version }}/ {print $1}' versions.txt)
export HUMHUB_VERSION
echo "HUMHUB_VERSION=$HUMHUB_VERSION" >> "$GITHUB_ENV"
- name: Download image archive (phponly)
uses: actions/download-artifact@v4.1.7
with:
name: build-${{ matrix.version }}-phponly
- name: Download image archive (nginx)
uses: actions/download-artifact@v4.1.7
with:
name: build-${{ matrix.version }}-nginx
- name: Load images
run: |
docker load --input build-${{ matrix.version }}-phponly.tar.gz
docker load --input build-${{ matrix.version }}-nginx.tar.gz
- name: replace image
run: |
sed -i "s/docker.io\/mriedmann\/humhub:stable-nginx/ghcr.io\/${GITHUB_REPOSITORY_OWNER}\/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-nginx/g" docker-compose.prod.yml
sed -i "s/docker.io\/mriedmann\/humhub:stable-phponly/ghcr.io\/${GITHUB_REPOSITORY_OWNER}\/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-phponly/g" docker-compose.prod.yml
- name: Spin up services
run: docker compose -f docker-compose.prod.yml up -d
- name: Wait
run: sleep 60
- name: Check status
run: docker ps -a
- name: Logs
run: docker compose logs
- name: Test
run: curl http://localhost:8080/ -L --fail && curl http://localhost:8080/ -L --fail -s | grep 'Sign in</button>' -q
- name: Test Email
run: docker compose exec -T humhub php /var/www/localhost/htdocs/protected/yii test/email 'test@example.com' | grep 'Message successfully sent!' -q
push_ghcr:
needs: ["test_aio", "test_prod"]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
strategy:
fail-fast: false
matrix:
version: ["latest", "stable", "legacy"]
target: ["allinone", "nginx", "phponly"]
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Login to registry
run: echo "${{ secrets.PAT }}" | docker login ghcr.io --username "${GITHUB_REPOSITORY_OWNER}" --password-stdin
- name: Set Humhub version
run: |
HUMHUB_VERSION=$(awk -e '$0 ~ /^([0-9\.]+) [0-9\.]+ ${{ matrix.version }}/ {print $1}' versions.txt)
export HUMHUB_VERSION
echo "HUMHUB_VERSION=$HUMHUB_VERSION" >> "$GITHUB_ENV"
- name: Download image archive
uses: actions/download-artifact@v4.1.7
with:
name: build-${{ matrix.version }}-${{ matrix.target }}
- name: Load, retag and Push images
run: |
docker load --input build-${{ matrix.version }}-${{ matrix.target }}.tar.gz
docker tag "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub:${GITHUB_REF_NAME_SLUG}-${HUMHUB_VERSION}-${{ matrix.target }}" "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub-${{ matrix.target }}:${HUMHUB_VERSION}"
docker push "ghcr.io/${GITHUB_REPOSITORY_OWNER}/humhub-${{ matrix.target }}:${HUMHUB_VERSION}"