Skip to content

Build and Publish Docker Image #14

Build and Publish Docker Image

Build and Publish Docker Image #14

name: Build and Publish Docker Image
on:
workflow_dispatch:
inputs:
release_tag:
description: "Release version to build"
required: true
revision:
description: "Revision number (optional)"
required: false
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Determine tag
id: determine_tag
run: |
revision="${{ github.event.inputs.revision }}"
if [ "$revision" ]; then
echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}-rev.$revision" >> "$GITHUB_ENV"
else
echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}" >> "$GITHUB_ENV"
fi
echo "PHOTON_VERSION=${{ github.event.inputs.release_tag }}" >> "$GITHUB_ENV"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
build-args: |
PHOTON_VERSION=${{ env.PHOTON_VERSION }}
push: true
tags: |
rtuszik/photon-docker:${{ env.RELEASE_TAG }}
rtuszik/photon-docker:latest
platforms: linux/amd64,linux/arm64
- name: Store the latest release
run: echo ${{ env.RELEASE_TAG }} > .last_release
if: success()
continue-on-error: false