Skip to content

Commit

Permalink
fixed publish yaml to work with gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Mar 28, 2022
1 parent bf6d4e7 commit 780782d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
jobs:
Build-and-push:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'

env:
ECR_REPOSITORY: ${{ secrets.AWS_REPO_NAME }}
Expand All @@ -36,7 +39,7 @@ jobs:
- name: Git checkout
uses: actions/checkout@v2

# Build docker image
# # Build docker image
- name: Build Docker image
id: build-image
run: docker build -t $IMAGE_NAME .
Expand Down Expand Up @@ -77,21 +80,29 @@ jobs:
docker push $DOCKERHUB_REPOSITORY/$IMAGE_NAME:$IMAGE_TAG
echo "::set-output name=image::$DOCKERHUB_REPOSITORY/$IMAGE_NAME:$IMAGE_TAG"
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@master
- id: 'auth'
if: github.event.inputs.gcp == 'true'
uses: ' '
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA }}

# Setup gcloud CLI
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
if: github.event.inputs.gcp == 'true'

- name: 'Use gcloud CLI'
run: 'gcloud info'

- name: Login to gcloud
if: github.event.inputs.gcp == 'true'
run: gcloud auth configure-docker -q

# Push image to Google Container Registry
- name: Tag abd push image to GCP container registry
- name: Tag and push image to GCP container registry
if: github.event.inputs.gcp == 'true'
run: |
gcloud auth configure-docker -q
docker tag $IMAGE_NAME:$IMAGE_TAG gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER
docker push gcr.io/$GCP_PROJECT_ID/$CONTAINER_REGISTRY_FOLDER:$IMAGE_TAG

0 comments on commit 780782d

Please sign in to comment.