Release docker images #11
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: Release docker images | |
on: | |
release: | |
types: [published] | |
tags: | |
- 'bot-v*' # for bot image releases | |
- 'sc2-v*' # for sc2 image releases | |
jobs: | |
validate_tag: | |
name: Validate release tag | |
runs-on: ubuntu-latest | |
outputs: | |
type: ${{ steps.validate.outputs.type }} | |
version: ${{ steps.validate.outputs.version }} | |
steps: | |
- name: Validate tag format | |
id: validate | |
run: | | |
TAG="${{ github.event.release.tag_name }}" | |
# Validate tag format and extract type | |
if [[ $TAG =~ ^(bot|sc2)-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
TYPE=${BASH_REMATCH[1]} | |
VERSION=${TAG#*-v} | |
echo "Tag format is valid" | |
echo "type=${TYPE}" >> $GITHUB_OUTPUT | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
else | |
echo "Error: Invalid tag format. Must be 'bot-v*.*.*' or 'sc2-v*.*.*'" | |
exit 1 | |
fi | |
push_docker_images: | |
name: Push docker images | |
needs: validate_tag | |
runs-on: ubuntu-latest | |
timeout-minutes: 90 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push bot image | |
run: | | |
export IMAGE_TYPE=${{ needs.validate_tag.outputs.type }} | |
export VERSION=${{ needs.validate_tag.outputs.version }} # Used in the docker-compose.yml file | |
echo "Building and pushing ${IMAGE_TYPE} image version ${VERSION}" | |
# Build and push the image | |
docker compose -f docker/docker-compose.yml build ${IMAGE_TYPE} || { | |
echo "Error: Docker build failed" | |
exit 1 | |
} | |
docker compose -f docker/docker-compose.yml push ${IMAGE_TYPE} || { | |
echo "Error: Docker push failed" | |
exit 1 | |
} | |
# Verify the push was successful | |
docker pull aiarena/arenaclient-${IMAGE_TYPE}-base:${VERSION} || { | |
echo "Error: Unable to verify pushed image" | |
exit 1 | |
} | |
echo "Successfully built and pushed ${IMAGE_TYPE} image version ${VERSION}" | |