Skip to content

Push Docker Images

Push Docker Images #18

# This workflow pushes the production docker image on every new tag.
name: Push Docker Images
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # ignore rc
env:
DOCKER_REPOSITORY: osmolabs/sqs
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Check out repo
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Parse tag
id: tag
run: |
VERSION=$(echo ${{ github.ref_name }} | sed "s/v//")
MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f 1)
MINOR_VERSION=$(echo $VERSION | cut -d '.' -f 2)
PATCH_VERSION=$(echo $VERSION | cut -d '.' -f 3)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
echo "MINOR_VERSION=$MINOR_VERSION" >> $GITHUB_ENV
echo "PATCH_VERSION=$PATCH_VERSION" >> $GITHUB_ENV
-
name: Build and Push Docker Images
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64
tags: |
${{ env.DOCKER_REPOSITORY }}:latest
${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}
${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
${{ env.DOCKER_REPOSITORY }}:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}