diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 1011ce51a..59abe6be0 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -33,7 +33,7 @@ on: jobs: Build-and-push: runs-on: ubuntu-latest - + env: ECR_REPOSITORY: ${{ secrets.AWS_REPO_NAME }} PUBLIC_ECR_URL: ${{ secrets.AWS_REPO_URL }} @@ -46,7 +46,7 @@ jobs: steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Build docker image - name: Build Docker image @@ -89,7 +89,7 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Tag and push the image to Docker Hub if: github.event.inputs.dockerHub == 'true' id: dockerhub-push-image @@ -113,17 +113,22 @@ jobs: - id: auth name: Authenticate to Google Cloud if: github.event.inputs.gcp == 'true' - uses: 'google-github-actions/auth@v0' + uses: 'google-github-actions/auth@v2' with: credentials_json: '${{ secrets.GCP_SA_KEY }}' # Set up Cloud SDK - name: Set up Cloud SDK - uses: google-github-actions/setup-gcloud@v0 + uses: google-github-actions/setup-gcloud@v2 if: github.event.inputs.gcp == 'true' with: project_id: ${{ secrets.GCP_PROJECT_ID }} + - name: Docker Auth + if: github.event.inputs.gcp == 'true' + run: |- + gcloud auth configure-docker us-docker.pkg.dev --quiet + # Push image to Google Container Registry - name: Tag and push image to GCP container registry if: github.event.inputs.gcp == 'true' @@ -131,14 +136,14 @@ jobs: gcloud auth configure-docker -q # Setting image tag to image tag input - docker tag $IMAGE_NAME gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER:$IMAGE_TAG + docker tag $IMAGE_NAME us-docker.pkg.dev/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER/$IMAGE_NAME:$IMAGE_TAG # Setting image to with github branch name - docker tag $IMAGE_NAME gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER:branch-${GITHUB_REF##*/} + docker tag $IMAGE_NAME us-docker.pkg.dev/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER/$IMAGE_NAME:branch-${GITHUB_REF##*/} # Setting image to with github sha - docker tag $IMAGE_NAME gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER:sha-${GITHUB_SHA} + docker tag $IMAGE_NAME us-docker.pkg.dev/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER/$IMAGE_NAME:sha-${GITHUB_SHA} echo "Pushing image to GCP container registry..." - docker push gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER --all-tags + docker push us-docker.pkg.dev/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER/$IMAGE_NAME --all-tags echo "Pushing image to GCP container registry with following tags:" echo "::set-output name=image::gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER:$IMAGE_TAG"