fix: installer #149
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: [push, pull_request] | |
jobs: | |
docker: | |
name: Docker image test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Modify scripts and get version | |
id: version | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const date = new Date(); | |
const year = date.getUTCFullYear(); | |
const month = `${date.getUTCMonth()+1}`.padStart(2, '0'); | |
const day = `${date.getUTCDate()}`.padStart(2, '0'); | |
const hour = `${date.getUTCHours()}`.padStart(2, '0'); | |
const minute = `${date.getUTCMinutes()}`.padStart(2, '0'); | |
const d = `${year}-${month}-${day}T${hour}-${minute}`; | |
core.setOutput('version', `${d}-${context.sha.substring(0, 7)}`); | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
# Test image build | |
- name: Copy configuration and move to dev for docker build | |
run: | | |
cp -r config/* dev/ | |
cp dev/aws.example.env dev/aws.env | |
cp dev/secret.example.php dev/secret.php | |
sed -i -r 's/mediawiki:latest/mediawiki:ci-test/g' docker-compose.yml | |
- name: Build a test image on amd64 and cache | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64 | |
cache-from: | | |
type=local,src=/tmp/.buildx-cache | |
cache-to: | | |
type=inline | |
type=local,dest=/tmp/.buildx-cache,mode=max | |
no-cache: ${{ contains(github.event.head_commit.message, '[no cache]') }} | |
build-args: BUILD_VER=${{ steps.version.outputs.version }} | |
load: true | |
push: false | |
tags: ghcr.io/shinycolorswiki/mediawiki:ci-test | |
- name: Docker compose up | |
run: docker compose up -d --force-recreate | |
# Test image | |
- name: Try access Main_Page (repeat 1s, timeout 3m) | |
timeout-minutes: 3 | |
if: success() || failure() | |
run: until curl -sL --fail-with-body "http://127.0.0.1:8080/wiki/Main_Page"; do sleep 1; done | |
- name: Test Editor | |
if: success() || failure() | |
run: curl -sL --fail-with-body "http://127.0.0.1:8080/w/index.php?title=Main_Page&action=edit" | |
- name: Test VisualEditor | |
if: success() || failure() | |
run: curl -sL --fail-with-body "http://127.0.0.1:8080/w/api.php?action=visualeditor&format=json&page=arbitrary_page&paction=parse&wikitext=arbitrary" | |
- name: Test Special:Version (timeout 1m) | |
timeout-minutes: 1 | |
if: success() || failure() | |
run: curl -sL --fail-with-body "http://127.0.0.1:8080/wiki/Special:Version" | |
- name: Test Special:MathStatus (timeout 1m) | |
timeout-minutes: 1 | |
if: success() || failure() | |
run: curl -sL --fail-with-body "http://127.0.0.1:8080/wiki/Special:MathStatus" | |
- name: Test /id/?curid=1 (timeout 1m) | |
timeout-minutes: 1 | |
if: success() || failure() | |
run: curl -sL --fail-with-body "http://127.0.0.1:8080/id/?curid=1" | |
- name: Test container healthy (timeout 1m) | |
timeout-minutes: 1 | |
if: success() || failure() | |
run: | | |
until [[ $(docker inspect --format='{{.State.Health.Status}}' docker-mediawiki-fastcgi-1) == "healthy" ]]; do \ | |
echo $(docker inspect --format='{{.State.Health}}' docker-mediawiki-fastcgi-1) && sleep 1 \ | |
; done | |
# Check test image logs | |
- name: Docker compose ps | |
if: success() || failure() | |
run: docker compose ps | |
- name: docker compose logs (fastcgi) | |
if: success() || failure() | |
run: docker compose logs | grep -i 'fastcgi-1' | |
- name: docker compose logs (http) | |
if: success() || failure() | |
run: docker compose logs | grep -i 'http-1' | |
- name: docker compose logs (others) | |
if: success() || failure() | |
run: docker compose logs | grep -iv 'fastcgi-1' | grep -iv 'http-1' | |
# Docker Registry login | |
- name: Login to GitHub Container Registry | |
if: ${{ github.repository_owner == 'ShinyColorsWiki' && github.ref == 'refs/heads/master' }} | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Quay.io Container Registry | |
uses: docker/login-action@v2 | |
if: ${{ github.repository_owner == 'ShinyColorsWiki' && github.ref == 'refs/heads/master' }} | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
# Build and push | |
- name: Build a multi-platform docker image and push (for master) | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
cache-from: | | |
type=local,src=/tmp/.buildx-cache | |
cache-to: | | |
type=inline | |
type=local,dest=/tmp/.buildx-cache-new,mode=max | |
build-args: BUILD_VER=${{ steps.version.outputs.version }} | |
load: false | |
no-cache: ${{ contains(github.event.head_commit.message, '[no cache]') }} | |
push: ${{ github.repository_owner == 'ShinyColorsWiki' && github.ref == 'refs/heads/master' }} | |
tags: | | |
ghcr.io/shinycolorswiki/mediawiki:latest | |
ghcr.io/shinycolorswiki/mediawiki:${{ github.sha }} | |
ghcr.io/shinycolorswiki/mediawiki:${{ steps.version.outputs.version }} | |
quay.io/shinycolorswiki/mediawiki:latest | |
quay.io/shinycolorswiki/mediawiki:${{ github.sha }} | |
quay.io/shinycolorswiki/mediawiki:${{ steps.version.outputs.version }} | |
- # Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
deploy: | |
name: Trigger deploy to upstream | |
runs-on: ubuntu-latest | |
needs: docker | |
if: ${{ github.repository_owner == 'ShinyColorsWiki' && github.ref == 'refs/heads/master' }} | |
steps: | |
- name: Repository Dispatch | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.BOT_PA_TOKEN }} | |
repository: ${{ secrets.REPO_NAME }} | |
event-type: update_deploy | |
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' |