-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (83 loc) · 3.12 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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