diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5f6a0ec..0479d7a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,7 +1,7 @@ name: 'Continuous Delivery' on: - push: + pull_request: #TODO: For testing branches: - "main" @@ -14,12 +14,11 @@ jobs: uses: actions/checkout@v3 # Authenticate to Google Cloud - - name: Authenticate to Google Cloud - env: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - run: | - echo "$GOOGLE_CREDENTIALS" > /tmp/google-credentials.json - gcloud auth activate-service-account --key-file=/tmp/google-credentials.json + - id: 'auth' + name: 'Authenticate to Google Cloud' + uses: 'google-github-actions/auth@v1' + with: + credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' # Build and push Docker image - name: Build and push Docker image @@ -27,8 +26,8 @@ jobs: CONTAINER_IMAGE_URL: ${{ secrets.CONTAINER_IMAGE_URL }} GCLOUD_REGION: ${{ secrets.GCLOUD_REGION }} run: | - docker build -t $CONTAINER_IMAGE_URL:latest . gcloud auth configure-docker $GCLOUD_REGION + docker build -t $CONTAINER_IMAGE_URL:latest . docker push $CONTAINER_IMAGE_URL:latest deploy: