Skip to content

fix action regestry #51

fix action regestry

fix action regestry #51

Workflow file for this run

name: Publish Docker Image
on:
push:
tags:
- '*'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Git tag
id: get_version
run: |
TAG=${GITHUB_REF##*/}
echo "tag=$TAG" >> $GITHUB_ENV
echo "repository=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# Docker Login
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Docker tag
run: |
if [ -z "${{ github.ref_name }}" ]; then
echo "VERSION=latest" >> $GITHUB_ENV
else
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
fi
# Docker Image Build
- name: Build and tag Docker image
run: |
IMAGE_NAME="twoplay/craftybot"
VERSION=$TAG
LOWERCASE_REPO=$repository
# Build Image
docker build -t $IMAGE_NAME:latest -t $IMAGE_NAME:$VERSION .
docker tag $IMAGE_NAME:latest ghcr.io/$LOWERCASE_REPO:latest
docker tag $IMAGE_NAME:$VERSION ghcr.io/$LOWERCASE_REPO:$VERSION
# Push to DockerHub
- name: Push DockerHub image
run: |
IMAGE_NAME="twoplay/craftybot"
VERSION=$TAG
docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$VERSION
# Push to GitHub Packages
- name: Push GitHub image
run: |
VERSION=$TAG
LOWERCASE_REPO=$repository
docker push ghcr.io/$LOWERCASE_REPO:latest
docker push ghcr.io/$LOWERCASE_REPO:$VERSION