diff --git a/.github/workflows/build-domjudge-container-PR.yml b/.github/workflows/build-domjudge-container-PR.yml new file mode 100644 index 00000000..2c399364 --- /dev/null +++ b/.github/workflows/build-domjudge-container-PR.yml @@ -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 diff --git a/.github/workflows/build-domjudge-container-release.yml b/.github/workflows/build-domjudge-container-release.yml new file mode 100644 index 00000000..872b3d98 --- /dev/null +++ b/.github/workflows/build-domjudge-container-release.yml @@ -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