-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create action for docker build scripts
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
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: If needed overwrite the DOMJUDGE_VERSION for this run | ||
run: | | ||
if [ ${{ env.DOMJUDGE_VERSION }} != "M.m.p" ]; then | ||
exit 0 | ||
fi | ||
apt update; apt install -y 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 |
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
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 |