Skip to content

Commit

Permalink
ci: refine docker image build / push step and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lladdy committed Nov 19, 2024
1 parent e9c30fa commit 4e99b86
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
57 changes: 32 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,37 @@ jobs:
timeout-minutes: 90

steps:
- uses: actions/checkout@v4
- 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
if: needs.validate_tag.outputs.type == 'bot'
run: |
# Set version for docker-compose
export BOT_VERSION=${{ needs.validate_tag.outputs.version }}
echo "Building and pushing bot image version ${BOT_VERSION}"
docker compose -f docker/docker-compose.yml build bot
docker compose -f docker/docker-compose.yml push bot
- 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}"
- name: Build and push sc2 image
if: needs.validate_tag.outputs.type == 'sc2'
run: |
# Set version for docker-compose
export SC2_VERSION=${{ needs.validate_tag.outputs.version }}
echo "Building and pushing sc2 image version ${SC2_VERSION}"
docker compose -f docker/docker-compose.yml build sc2
docker compose -f docker/docker-compose.yml push sc2
8 changes: 2 additions & 6 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ version: "3.9"
services:
sc2:
restart: unless-stopped
image: aiarena/arenaclient-sc2-base:${SC2_VERSION:-latest}
image: aiarena/arenaclient-sc2-base:${VERSION:-latest}
build:
context: ../
dockerfile: ./docker/Dockerfile.sc2
args:
SC2_VERSION: "${SC2_VERSION}"

bot:
restart: unless-stopped
image: aiarena/arenaclient-bot-base:${BOT_VERSION:-latest}
image: aiarena/arenaclient-bot-base:${VERSION:-latest}
build:
context: ../
dockerfile: ./docker/Dockerfile.bot
args:
PYTHON_VERSION: "${PYTHON_VERSION}"

0 comments on commit 4e99b86

Please sign in to comment.