RafikFarhad / push-to-gcr-github-action

An action that build docker image and push to Google Cloud Registry and Google Artifact Registry.
MIT License
68 stars 37 forks source link

Use GITHUB_SHA as image_tag #29

Closed Shaun-Harrison closed 2 years ago

Shaun-Harrison commented 2 years ago

Hello!

This may just be being an idiot, but I'd like to use the environment variable GITHUB_SHA as the tag for the image I'm trying to push

      - name: Build Prod Container
        uses: RafikFarhad/push-to-gcr-github-action@v4.1
        if: github.ref == 'refs/heads/main'
        with:
          gcloud_service_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
          registry: gcr.io
          project_id:  ${{ secrets.GCR_PROJECT }}
          image_name: ${{ secrets.GCR_NAME }}
          image_tag: main, $GITHUB_SHA
          dockerfile: ./hello-world/Dockerfile

But I get the following

Error parsing reference: "gcr.io/***/***:$GITHUB_SHA" is not a valid repository/tag: invalid reference format
Pushing image gcr.io/***/***:$GITHUB_SHA...
invalid reference format

Any suggestions on the correct syntax for this

Shaun-Harrison commented 2 years ago

I was being an idiot :D

Answer is

image_tag: main, ${{ github.sha }}