This commit is contained in:
Shahrad Elahi 2023-10-02 14:49:36 +03:30
parent 23b9cf2a1b
commit cb6f8f4ba3

View File

@ -9,8 +9,6 @@ on:
env:
IMAGE_NAME: shahradelahi/wireadmin
# By default, image tag is the commit SHA
IMAGE_TAG: ${{ github.sha }}
jobs:
build:
@ -29,13 +27,18 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.PRIVATE_TOKEN }}
# if it was a release tag, use the tag as the image tag
# If it was a release tag, use the tag as the image tag,
# and otherwise image tag is the commit SHA
- name: Set image tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG//./-}" >> $GITHUB_ENV
echo "RELEASE_TAG=,ghcr.io/${IMAGE_NAME}:latest" >> $GITHUB_ENV
if [[ $GITHUB_REF == refs/tags/v* ]]; then
echo "Labeling image with TAG: ${GITHUB_REF#refs/tags/v}"
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
else
echo "Labeling image with commit SHA: ${GITHUB_SHA}"
echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_ENV
fi
- name: Push to GitHub Container Registry
uses: docker/build-push-action@v4