MicrosoftDocs / mslearn-aks-deployment-pipeline-github-actions

Sample code for the MS Learn module for AKS with GitHub Actions
Creative Commons Attribution 4.0 International
18 stars 677 forks source link

buildx failed with: error: invalid tag "***/contoso-website:${GITHUB_REF#refs/tags}": invalid reference format #7

Open iamalexmang opened 3 years ago

iamalexmang commented 3 years ago

I'm getting buildx failed with: error: invalid tag "***/contoso-website:${GITHUB_REF#refs/tags}": invalid reference format for the production builds.

iamalexmang commented 3 years ago

image

shakian-jh commented 3 years ago

Hi @iamalexmang, You can fix it by setting the branch and passing it with the build-args. Please see code below.

    steps:
      - uses: actions/checkout@v2

      - name: Set BRANCH
        run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV      

      - name: Set up Buildx
        uses: docker/setup-buildx-action@v1
<skipped>
      - name: Build and push production image
        uses: docker/build-push-action@v2.6.1
        with:
          context: .
          tags: ${{secrets.ACR_NAME}}/contoso-website:latest,${{secrets.ACR_NAME}}/contoso-website:${{ env.BRANCH }}
          push: true
          build-args: |
              BRANCH=${{ env.BRANCH }}