Skip to content

Initial commit

Initial commit #1

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
branches:
- main
workflow_dispatch:
inputs:
ref:
description: 'Git reference to checkout (branch, tag, or SHA)'
required: true
default: 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set Docker image tags
id: tags
run: |
TAGS="${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:${{ github.sha }}"
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.event.inputs.ref }}" == "main" ]]; then
TAGS="$TAGS,${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:latest"
fi
echo "::set-output name=tags::$TAGS"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}