Skip to content

Separate git clone flags #2

Separate git clone flags

Separate git clone flags #2

# this jobs compares ./devcontainer/dodona-tested.dockerfile with the dockerfile in the repository dodona-edu/docker-images
# if they are different, a pull request is created in the dodona-edu/docker-images repository
name: Create pr for docker image
on:
push:
pull_request:
types:
- closed
branches:
- main
jobs:
pr:
# if: github.event.pull_request.merged == true
name: Create pr for docker image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Send pull-request
env:
PR_NUMBER: ${{ github.event.number }}
REPOSITORY: dodona-edu/docker-images
TOKEN: ${{ secrets.PUSH_TO_DOCKER_IMAGES_ACCESS_TOKEN }}
run: |
FOLDER="$REPOSITORY"
BRANCH_NAME="update-dodona-tested-$PR_NUMBER"
# Store the PAT in a file that can be accessed by the
# GitHub CLI.
echo "$TOKEN" > token.txt
# Authorize GitHub CLI for the current repository
gh auth login --with-token < token.txt
gh repo clone $REPOSITORY $FOLDER -- --depth=1
cd $FOLDER
# Setup the committers identity.
gh auth setup-git
# Create a new feature branch for the changes.
git checkout -b $BRANCH_NAME
# Update the dockerfile to the latest version
cp ../.devcontainer/dodona-tested.dockerfile .
# Add header to the dockerfile to make it clear that it is autogenerated
sed -i '1s/^/# This file is autogenerated by the dodona-edu/universal-judge repository\n # Any changes will be overwritten by the CI\n\n/' dodona-tested.dockerfile
# check git status if the dockerfile has changed
# if not, exit
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to the dockerfile"
exit 0
fi
# Commit the changes and push the feature branch to origin
git commit -am "Chore: update dodona-tested dockerfile"
git push origin $BRANCH_NAME
# Create a pull request in the remote repository
gh pr create \
--body "" \
--title "Update dodona-tested dockerfile to match pr #$PR_NUMBER" \
--body "This pr updates the dodona-tested dockerfile to match pr https://github.com/dodona-edu/universal-judge/pull/$PR_NUMBER" \
--head "$BRANCH_NAME" \
--base "master"