-
-
Notifications
You must be signed in to change notification settings - Fork 7
114 lines (100 loc) · 4.17 KB
/
docker-femiwiki.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
name: 'Docker: femiwiki'
on:
push:
paths:
- 'dockers/femiwiki/**'
- .github/workflows/docker-femiwiki.yml
pull_request:
paths:
- 'dockers/femiwiki/**'
- .github/workflows/docker-femiwiki.yml
workflow_dispatch:
jobs:
docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Edit configuration
run: |
mv development/secret.php.example development/secret.php
mv dockers/femiwiki/LocalSettings.php development
mv dockers/femiwiki/Hotfix.php development
sed -i -r 's~ghcr\.io\/femiwiki\/femiwiki:.+~ghcr\.io\/femiwiki\/femiwiki:docker-test~' docker-compose.yml
- run: |
echo "version=$(date +%Y-%m-%dT%H-%M)-$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_OUTPUT
id: version
- uses: docker/build-push-action@v5
with:
context: '{{ defaultContext }}:dockers/femiwiki'
platforms: linux/amd64
cache-from: ghcr.io/femiwiki/femiwiki:latest
cache-to: mode=max,type=local,dest=/tmp/.buildx-cache
load: true
push: false
tags: ghcr.io/femiwiki/femiwiki:docker-test
- name: Initialize docker swarm and start services
run: |
docker swarm init
docker stack deploy -c docker-compose.yml mediawiki
- name: Access 127.0.0.1:8080 until success
timeout-minutes: 2
run: |
echo 'Waiting for http...'
until curl -sLfo /dev/null 127.0.0.1:8080; do
sleep 1; done
- name: Test VisualEditor API
run: |
URL="127.0.0.1:8080/api.php?action=visualeditor&format=json&page=arbitrary_page&paction=parse&wikitext=arbitrary"
curl -sLfo /dev/null "$URL"
- name: Test Extension:Math
timeout-minutes: 1
run: |
URL="127.0.0.1:8080/w/Special:MathStatus"
until curl -sLfo /dev/null "$URL"; do
sleep 1; done
- name: backup of failure
if: ${{ failure() }}
timeout-minutes: 1
run: |
echo 'Failed to connect to 127.0.0.1:8080'
URL="127.0.0.1:8080/api.php?action=visualeditor&format=json&page=arbitrary_page&paction=parse&wikitext=arbitrary"
curl -Lv "$URL" && echo "VE success" || echo "VE failure"
URL="127.0.0.1:8080/w/Special:MathStatus"
curl -Lv "$URL" && echo "Math success" || echo "Math failure"
docker ps;
for s in $(docker service ls -q ); do docker service ps "$s"; done
docker container ps;
for s in $(docker service ls -q ); do docker service logs "$s"; done
- name: Check if the container is still up
run: test "$(docker service ps -qf 'desired-state=Running' -f 'desired-state=Ready' mediawiki_fastcgi)"
- name: Try to access the mediawiki
run: curl -sSLvo /dev/null 127.0.0.1:8080 || docker service logs mediawiki_fastcgi
- uses: docker/login-action@v3
if: github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build a multi-platform docker image and push
uses: docker/build-push-action@v5
with:
context: '{{defaultContext}}:dockers/femiwiki'
platforms: linux/amd64,linux/arm64
cache-from: |
ghcr.io/femiwiki/femiwiki:latest
type=local,src=/tmp/.buildx-cache
cache-to: mode=max,type=inline
load: false
push: ${{ github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/femiwiki/femiwiki:latest
ghcr.io/femiwiki/femiwiki:${{ steps.version.outputs.version }}
- name: Submit a PR to our nomad repository
if: github.repository_owner == 'femiwiki' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
gh workflow run -R femiwiki/nomad bump-mediawiki.yml \
-f tag=${{ steps.version.outputs.version }}