Skip to content

Commit

Permalink
feat(gha): add docker push github action
Browse files Browse the repository at this point in the history
  • Loading branch information
georgettica authored Oct 8, 2024
1 parent 6802cc6 commit 0801bce
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/push-docker-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and Push Docker Image

on:
release:
types: [published]
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to build and push"
required: true

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine the release tag
id: get_tag
run: |
if [ "${{ github.event_name }}" == "release" ]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.event.inputs.release_tag }}" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.get_tag.outputs.tag }}

0 comments on commit 0801bce

Please sign in to comment.