Skip to content

Commit

Permalink
Create action for docker build scripts
Browse files Browse the repository at this point in the history
The PRs for changes to those scripts will be stored in the registry
of the user/organisation which forked or in our GitHub docker registry
if this branch is under the domjudge organization. Here we always build
against our latest version.

The GitLab code had the option to not push the latest tag, for when we
rebuild an older container, otherwise we always release against the
overwritten value or if nothing was provided against the latest released
tag (so which latest points to).
  • Loading branch information
vmcj committed Jan 12, 2024
1 parent 69e41f6 commit 12a6bcc
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-domjudge-container-PR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Build domjudge container (PR)'

on:
push:
pull_request_target:
branches:
- main

env:
DOMJUDGE_VERSION: M.m.p

jobs:
pr-domjudge:
if: ${{ github.repository != 'domjudge/domjudge-packaging' || github.ref != 'main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}

- name: If needed overwrite the DOMJUDGE_VERSION for this run
run: |
if [ ${{ env.DOMJUDGE_VERSION }} != "M.m.p" ]; then
exit 0
fi
apk add jq curl
set -x
HUBURL="https://registry.hub.docker.com/v2/repositories/domjudge/domserver/tags"
TAG=$(curl $HUBURL|jq '.results | sort_by(.name) | .[length-2].name')
DJ_TAG=${TAG//\"}
set +x
echo "DOMJUDGE_VERSION=$DJ_TAG" >> $GITHUB_ENV
- name: Build the container
run: |
cd docker
set -x
sh ./build.sh "${{ env.DOMJUDGE_VERSION }}"
set +x
- name: Build and push
run: |
for IMG in domserver judgehost default-judgehost-chroot; do
docker push domjudge/$IMG:${{ env.DOMJUDGE_VERSION }}
done
65 changes: 65 additions & 0 deletions .github/workflows/build-domjudge-container-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Build domjudge container (Release)'

on:
push:
pull_request_target:
branches:
- main

env:
DOMJUDGE_VERSION: M.m.p
DOMJUDGE_LATEST: true

jobs:
release-domjudge:
if: ${{ github.repository == 'domjudge/domjudge-packaging' && github.ref == 'main' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: If needed overwrite the DOMJUDGE_VERSION for this run
run: |
if [ ${{ env.DOMJUDGE_VERSION }} != "M.m.p" ]; then
exit 0
fi
if [ ${{ env.DOMJUDGE_LATEST }} == "false" ]; then
echo "I don't know which version to pick!"
exit 1
fi
apk add jq curl
set -x
HUBURL="https://registry.hub.docker.com/v2/repositories/domjudge/domserver/tags"
TAG=$(curl $HUBURL|jq '.results | sort_by(.name) | .[length-2].name')
DJ_TAG=${TAG//\"}
set +x
echo "DOMJUDGE_VERSION=$DJ_TAG" >> $GITHUB_ENV
- name: Build the container
run: |
cd docker
set -x
sh ./build.sh "${{ env.DOMJUDGE_VERSION }}"
set +x
- name: Build and push
run: |
for IMG in domserver judgehost default-judgehost-chroot; do
docker push domjudge/$IMG:${{ env.DOMJUDGE_VERSION }}
if [ ${{ env.DOMJUDGE_LATEST }} = "true" ]; then
docker tag domjudge/$IMG:${{ env.DOMJUDGE_VERSION }} domjudge/$IMG:latest
docker push domjudge/$IMG:latest
fi
done

0 comments on commit 12a6bcc

Please sign in to comment.