Build and Publish DOMjudge #77
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 Publish DOMjudge | |
on: | |
schedule: | |
- cron: '0 2 * * *' # Runs every day at 2 AM Z | |
workflow_dispatch: | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
status: ${{ steps.check-commit.outcome }} | |
steps: | |
- name: Checkout DOMjudge Repository | |
uses: actions/checkout@v3 | |
with: | |
repository: 'domjudge/domjudge' | |
ref: 'main' | |
path: 'domjudge' | |
# If the version contains DEV, add the hash. | |
- name: Get Version and Set TAG | |
run: | | |
cd domjudge | |
VERSION=$(grep 'version' README.md | sed -n '1s/^.*version //p') | |
[[ $VERSION == *DEV* ]] && TAG="${VERSION}-$(git rev-parse --short=7 HEAD)" || TAG="${VERSION}" | |
echo "TAG=${TAG}" >> $GITHUB_ENV | |
- name: Check if the Image with Specific Tag Exists | |
id: check-commit | |
continue-on-error: true | |
run: | | |
REPO='itsniklas/domjudge-domserver-nightly' | |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://hub.docker.com/v2/repositories/${REPO}/tags/${{ env.TAG }}) | |
if [ "$STATUS" -eq 200 ]; then | |
echo "Image exists." | |
else | |
echo "Image does not exist." | |
exit 1 | |
fi | |
build: | |
needs: check | |
if: needs.check.outputs.status == 'failure' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout DOMjudge Repository | |
uses: actions/checkout@v3 | |
with: | |
repository: 'domjudge/domjudge' | |
ref: 'main' | |
path: 'domjudge' | |
# If the version contains DEV, add the hash. | |
- name: Get Version and Set TAG | |
run: | | |
cd domjudge | |
VERSION=$(grep 'version' README.md | sed -n '1s/^.*version //p') | |
[[ $VERSION == *DEV* ]] && TAG="${VERSION}-$(git rev-parse --short=7 HEAD)" || TAG="${VERSION}" | |
echo "TAG=${TAG}" >> $GITHUB_ENV | |
- name: Checkout DOMjudge Docker Repository | |
uses: actions/checkout@v3 | |
with: | |
path: 'domjudge-docker' | |
- name: Create DOMjudge Snapshot | |
run: tar -czf domjudge-docker/domjudge-packaging/docker/domjudge.tar.gz domjudge | |
- name: Build DOMjudge | |
run: | | |
cd domjudge-docker/domjudge-packaging/docker/ | |
./build-domjudge.sh itsniklas/domjudge-domserver-nightly:${{ env.TAG }} | |
docker tag itsniklas/domjudge-domserver-nightly:${{ env.TAG }} itsniklas/domjudge-domserver-nightly:latest | |
- name: Build Judgehost | |
run: | | |
cd domjudge-docker/domjudge-packaging/docker/ | |
./build-judgehost.sh itsniklas/domjudge-judgehost-nightly:${{ env.TAG }} | |
docker tag itsniklas/domjudge-judgehost-nightly:${{ env.TAG }} itsniklas/domjudge-judgehost-nightly:latest | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Publish DOMjudge Image | |
run: | | |
docker push itsniklas/domjudge-domserver-nightly:${{ env.TAG }} | |
docker push itsniklas/domjudge-domserver-nightly:latest | |
- name: Publish Judgehost Image | |
run: | | |
docker push itsniklas/domjudge-judgehost-nightly:${{ env.TAG }} | |
docker push itsniklas/domjudge-judgehost-nightly:latest | |