Skip to content

Commit

Permalink
add workflow to publish docker image (#369)
Browse files Browse the repository at this point in the history
* add workflow to publish docker image

This workflow intended to be triggered manually from the Actions tab.

* Push to trigger docker workflow

* update

* update

* resolve #366

* update

* add release tag to docker image

* publish docker image on release or manual

* echo tag in output

* update

* trigger

* update

* update

* fetch tags

* simplify loop, debug output

* update to checkout@v4

* revert back to checkout@v3, add explicit fetch

* remove shallow

* update

* update

* Update docker.yml

* clean up

* Update docker.yml
  • Loading branch information
keski authored Oct 4, 2024
1 parent ec67a2f commit 4102798
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Publish Docker image to GHCR

on:
workflow_dispatch: # allows manual triggers via the GitHub UI
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main

# Fetch all tags
- name: Fetch tags
run: |
git fetch --prune --tags
# Set up Docker Buildx for cross-platform builds (optional but recommended)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

# Build and tag the Docker image
- name: Build Docker image
run: |
cd hefquin-docker/
docker build -t ghcr.io/liusemweb/hefquin:latest .
- name: Tag and push Docker image
run: |
# Get the tags for the current commit and add to image
# Loop tags
tags=$(git tag --points-at HEAD)
for tag in $tags; do
echo "Adding tag: $tag"
docker tag ghcr.io/liusemweb/hefquin:latest ghcr.io/liusemweb/hefquin:$tag
done
# Push the Docker image to GitHub Container Registry (GHCR)
- name: Push Docker image to GHCR
run: |
docker push ghcr.io/liusemweb/hefquin --all-tags

0 comments on commit 4102798

Please sign in to comment.