fix(create-new-release.yml): update client-payload to use github.ref_… #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker Image to GHCR | |
on: | |
push: | |
paths: | |
- 'Dockerfile' | |
- '.github/workflows/publish-docker-image.yml' | |
repository_dispatch: | |
types: [publish-docker-image] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Docker image tag' | |
required: true | |
default: 'nightly' | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set TAG variable | |
run: | | |
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then | |
TAG="${{ github.event.client_payload.tag }}" | |
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
TAG="${{ github.event.inputs.tag }}" | |
elif [ "${{ github.event_name }}" == "push" ]; then | |
if [[ "${{ github.event.head_commit.message }}" == *"Update publish-docker-image.yml"* ]]; then | |
TAG="test" | |
else | |
TAG="nightly" | |
fi | |
else | |
echo "Unsupported event: ${{ github.event_name }}" | |
exit 1 | |
fi | |
if [ -z "$TAG" ]; then | |
echo "TAG is not defined. Please ensure that the tag is set in your environment variables or input parameters." | |
exit 1 | |
fi | |
echo "TAG=$TAG" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
run: | | |
docker buildx build \ | |
--tag ghcr.io/${{ github.repository_owner }}/yourip:${TAG} \ | |
--push . | |
- name: Logout from GHCR | |
run: docker logout ghcr.io |