Automatic Publish (2024 Pre) #1074
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: Automatic Publish (2024 Pre) | |
on: | |
schedule: | |
- cron: '0 */2 * * *' | |
jobs: | |
setup-build-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get latest release tag | |
id: get_latest_release_tag | |
run: | | |
LATEST=$(curl -s https://api.github.com/repos/tModLoader/tModLoader/releases | jq -r "[.[] | select(.tag_name | contains(\"2024\")) | select(.prerelease == true)] | max_by(.created_at) | .tag_name | sub(\"^v\";\"\")") | |
echo "Latest 2024 pre-release is ${LATEST}." >> "$GITHUB_STEP_SUMMARY" | |
echo "latest_tag=$LATEST" >> "$GITHUB_OUTPUT" | |
- name: Check if version is already published | |
run: | | |
CHECK=$(curl -s "https://hub.docker.com/v2/repositories/passivelemon/tmodloader1.4-docker/tags/${{ steps.get_latest_release_tag.outputs.latest_tag }}") | |
echo $CHECK | |
if echo "${CHECK}" | jq -e ".digest" > /dev/null; then | |
echo "Version ${{ steps.get_latest_release_tag.outputs.latest_tag }} is already published." >> "$GITHUB_STEP_SUMMARY" | |
exit 1 | |
fi | |
echo "Version ${{ steps.get_latest_release_tag.outputs.latest_tag }} is not already published." >> "$GITHUB_STEP_SUMMARY" | |
- 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: passivelemon | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64 | |
build-args: VERSION=${{ steps.get_latest_release_tag.outputs.latest_tag }} | |
tags: | | |
passivelemon/tmodloader1.4-docker:latest-2024-pre | |
passivelemon/tmodloader1.4-docker:${{ steps.get_latest_release_tag.outputs.latest_tag }} | |
ghcr.io/passivelemon/tmodloader1.4-docker:latest-2024-pre | |
ghcr.io/passivelemon/tmodloader1.4-docker:${{ steps.get_latest_release_tag.outputs.latest_tag }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |