Use latest ubuntu for maintainer container #54
Workflow file for this run
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 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 == 'refs/heads/main') && | |
!contains(github.ref, 'gh-readonly-queue') && | |
(github.event_name == 'pull_request_target' || | |
github.event.pull_request.head.repo.full_name != github.repository) }} | |
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 GitHub container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: docker system prune -a -f | |
- name: Get an unique tag for when people PR often | |
run: | | |
GHR=${{ github.ref }} | |
echo "PR_TAG=${GHR///}${{ github.actor }}" >> $GITHUB_ENV | |
- name: If needed overwrite the DOMJUDGE_VERSION for this run | |
run: | | |
if [ ${{ env.DOMJUDGE_VERSION }} != "M.m.p" ]; then | |
exit 0 | |
fi | |
sudo apt update; sudo apt install -y jq curl | |
set -x | |
HUBURL="https://registry.hub.docker.com/v2/repositories/domjudge/domserver/tags" | |
TAG=$(curl $HUBURL|jq '.results | sort_by(.name) | .[-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 }}" ${{ github.actor }} | |
set +x | |
- run: docker image list | |
- name: Build and push | |
run: | | |
for IMG in domserver judgehost default-judgehost-chroot; do | |
IMAGE_NAME="${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.DOMJUDGE_VERSION }}" | |
docker image tag "$IMAGE_NAME" ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }} | |
docker image tag "$IMAGE_NAME" ${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }} | |
docker push ghcr.io/${GITHUB_REPOSITORY_OWNER@L}/$IMG:${{ env.PR_TAG }} | |
done | |
- name: Check for wrong permisions | |
run: | | |
docker image list | |
set -x | |
for IMG in domserver judgehost; do | |
files=$(docker run --rm --pull=never "${{ github.repository_owner }}/$IMG:${{ env.PR_TAG }}" find / -xdev -perm -o+w ! -type l ! \( -type d -a -perm -+t \) ! -type c) | |
if [ -n "$files" ]; then | |
echo "error: image ${{ github.repository_owner }}/$IMG:${{ env.PR_TAG }} contains world-writable files:" >&2 | |
printf "%s\n" "$files" >&2 | |
exit 1 | |
fi | |
done | |