Skip to content

📦 [younsl/hugo] Release hugo image (arm64) #16

📦 [younsl/hugo] Release hugo image (arm64)

📦 [younsl/hugo] Release hugo image (arm64) #16

Workflow file for this run

name: Release hugo image
run-name: 📦 [younsl/hugo] Release hugo image (arm64)
on:
workflow_dispatch:
env:
IMAGE_NAME: younsl/hugo
HUGO_VERSION: 0.143.0
permissions:
contents: read
packages: write
jobs:
check:
runs-on: ubuntu-24.04-arm
outputs:
image_exists: ${{ steps.image_check.outputs.image_exists }}
steps:
- name: Check if image exists on GitHub Container Registry
id: image_check
run: |
ENCODED_TOKEN=$(echo -n "${{ secrets.GITHUB_TOKEN }}" | base64)
TAGS=$(curl -s -H "Authorization: Bearer ${ENCODED_TOKEN}" \
https://ghcr.io/v2/${{ env.IMAGE_NAME }}/tags/list)
echo "TAGS: $TAGS"
## Check if TAGS is empty or null
if [[ -z "$TAGS" || "$TAGS" == "null" ]]; then
echo "No tags found, treating as image not existing."
echo "image_exists=false" >> $GITHUB_OUTPUT
else
## Check if the specific tag already exists
if echo "$TAGS" | jq -e --arg TAG "${{ env.HUGO_VERSION }}" '.tags | index($TAG)'; then
echo "Image with tag ${{ env.HUGO_VERSION }} already exists."
echo "image_exists=true" >> $GITHUB_OUTPUT
else
echo "Image with tag ${{ env.HUGO_VERSION }} not found."
echo "image_exists=false" >> $GITHUB_OUTPUT
fi
fi
release:
runs-on: ubuntu-24.04-arm
needs: check
if: ${{ needs.check.outputs.image_exists == 'false' }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Login to GitHub Container Registry (ghcr.io)
id: login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
id: build
run: |
docker build \
-t ghcr.io/${{ env.IMAGE_NAME }}:${{ env.HUGO_VERSION }} \
-f box/dockerfiles/hugo/Dockerfile .
- name: Push
id: push
run: |
docker push ghcr.io/${{ env.IMAGE_NAME }}:${{ env.HUGO_VERSION }}