diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index 821fee1..7134a24 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -3,7 +3,10 @@ name: Build and Push Docker Image on: push: branches: - - '*' + - main + - build + tags: + - '*' # Push events to all tags env: DOCKERHUB_USERNAME: jordotech @@ -21,9 +24,19 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Get branch name - id: branch_name - run: echo ::set-output name=branch::${GITHUB_REF#refs/heads/} + - name: Get branch or tag name + id: branch_or_tag_name + run: echo ::set-output name=name::${GITHUB_REF#refs/*/} + + - name: Determine tag + id: image_tag + run: | + if [[ "${{ steps.branch_or_tag_name.outputs.name }}" == "tags"* ]]; then + echo "::set-output name=tag::${{ steps.branch_or_tag_name.outputs.name#tags/ }}" + else + echo "::set-output name=tag::${{ github.sha }}" + fi + - name: Login to Docker Hub uses: docker/login-action@v1 with: