Build Steam Docker Image and Deploy #150
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: Build Steam Docker Image and Deploy | |
on: | |
# Run on every main branch push | |
push: | |
branches: [ "main" ] | |
# Run every day at midnight | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
# Deploy a new image to DockerHub | |
build-and-publish-dockerhub: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
# Build all supported container images | |
- name: Build Containers | |
run: make all | |
# Authenticate with DockerHub prior to publishing | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
# Publish our built container images | |
- name: Push Docker images to DockerHub | |
run: | | |
# Push the default tags to DockerHub | |
docker push thetestgame/steam:stable | |
docker push thetestgame/steam:latest | |
docker push thetestgame/steam:winehq | |
docker push thetestgame/steam:experimental | |
# Only add SHA tags if the event is a push to the main branch | |
if [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/heads/main' ]]; then | |
# Retrieve the short SHA | |
SHORT_SHA=$(git rev-parse --short HEAD) | |
# Tag and push the images with the new tags | |
docker tag thetestgame/steam:stable thetestgame/steam:stable-$SHORT_SHA | |
docker tag thetestgame/steam:latest thetestgame/steam:latest-$SHORT_SHA | |
docker tag thetestgame/steam:winehq thetestgame/steam:winehq-$SHORT_SHA | |
docker tag thetestgame/steam:experimental thetestgame/steam:experimental-$SHORT_SHA | |
docker push thetestgame/steam:stable-$SHORT_SHA | |
docker push thetestgame/steam:latest-$SHORT_SHA | |
docker push thetestgame/steam:winehq-$SHORT_SHA | |
docker push thetestgame/steam:experimental-$SHORT_SHA | |
fi | |
# Keep the workflow alive | |
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings | |
# Update our DockerHub README | |
docker-hub-description: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: thetestgame/steam |