diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce0c357..f3c1b76 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,8 @@ name: Docker Build & Push on: push: - tags: - - "*" + branches: + - main workflow_dispatch: # Allows you to run this workflow manually from the Actions tab env: @@ -33,9 +33,11 @@ jobs: if: success() id: prepare run: | - echo "docker_platform=${DOCKER_TARGET_PLATFORM}" >> $GITHUB_OUTPUT - echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - + re="^FROM caddy:([^-]+)" + str=$(cat Dockerfile) + tag=$(if [[ $str =~ $re ]]; then echo ${BASH_REMATCH[1]}; else exit 1; fi) + echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -69,3 +71,8 @@ jobs: ghcr.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:${{ steps.prepare.outputs.tag }} quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.prepare.outputs.tag }}