Skip to content

Build and push latest GHCR Docker image #3

Build and push latest GHCR Docker image

Build and push latest GHCR Docker image #3

name: Build and push latest GHCR Docker image
on:
workflow_call:
secrets:
DOCKER_GHCR:
description: Docker GHCR token
required: true
inputs:
git_tag_name:
required: true
type: string
workflow_dispatch:
inputs:
git_tag_name:
description: Git version tag (eg. v0.9.0)
required: true
jobs:
push-image:
name: Push latest image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.DOCKER_GHCR }}
- name: Fetch all tags
run: git fetch --tags
- name: Build Docker image
run: docker build -t tinted-builder-rust .
- name: Tag Docker image
run: |
docker tag tinted-builder-rust ghcr.io/tinted-theming/tinted-builder-rust:${{ inputs.git_tag_name }}
docker tag tinted-builder-rust ghcr.io/tinted-theming/tinted-builder-rust:latest
- name: Log in to GitHub Container Registry
run: echo ${{ secrets.DOCKER_GHCR }} | docker login ghcr.io -u tinted-theming-bot --password-stdin
- name: Push Docker image
run: |
docker push ghcr.io/tinted-theming/tinted-builder-rust:${{ inputs.git_tag_name }}
docker push ghcr.io/tinted-theming/tinted-builder-rust:latest
- name: Remove existing 'latest' tag
run: |
if git rev-parse latest >/dev/null 2>&1; then
git tag -d latest
git push origin :refs/tags/latest
fi
- name: Add 'latest' tag to LATEST_TAG commit
run: |
git_tag_commit_hash=$(git rev-list -n 1 ${{ inputs.git_tag_name }})
git tag latest ${git_tag_commit_hash}
git push origin latest