Skip to content

Check for new OpenRA release and build docker image #80

Check for new OpenRA release and build docker image

Check for new OpenRA release and build docker image #80

Workflow file for this run

name: Check for new OpenRA release and build docker image
on:
schedule:
- cron: '0 22 * * *' # Runs every day at 22:00
workflow_dispatch:
inputs:
version:
description: 'OpenRA version to build'
required: false
default: ''
jobs:
check-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get OpenRA version from input or latest release
id: version
run: |
if [ "${{ github.event.inputs.version }}" != "" ]; then
echo "OPENRA_RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
# Your current code to retrieve the latest version
OPENRA_RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/OpenRA/OpenRA/releases" | grep '"tag_name":' | grep 'release-' | sed -E 's/.*"([^"]+)".*/\1/' | cut -d'-' -f2- | head -n 1)
echo "OPENRA_RELEASE_VERSION=$OPENRA_RELEASE_VERSION" >> $GITHUB_ENV
fi
- name: Check if versions match
id: check
run: |
if [ "$OPENRA_RELEASE_VERSION" != "$(cat version.txt)" ]; then
echo "NEW_RELEASE=true" >> $GITHUB_ENV
fi
- name: Login to GitHub Container Registry
if: env.NEW_RELEASE == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
if: env.NEW_RELEASE == 'true'
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image if new release
if: env.NEW_RELEASE == 'true'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.OPENRA_RELEASE_VERSION }}
ghcr.io/${{ github.repository }}:latest
build-args: OPENRA_RELEASE_VERSION=${{ env.OPENRA_RELEASE_VERSION }} # pass the release version as build-arg to docker build
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 # the platforms, linux/ppc64le runs out of memory :( linux/arm/v5 lua lib problem
- name: Update and commit new version
if: env.NEW_RELEASE == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo $OPENRA_RELEASE_VERSION > version.txt
git add version.txt
git commit -m "New OpenRA release $OPENRA_RELEASE_VERSION detected, starting docker image build"
git push