authorize from header #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
env: | |
SERVICE_NAME: ${{ secrets.SERVICE_NAME }} | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
GCP_REGION: ${{ secrets.GCP_REGION }} | |
IMAGE: asia.gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.SERVICE_NAME }}:${{ github.sha }} | |
API_KEY: ${{ secrets.API_KEY }} | |
jobs: | |
deploy-to-cloud-run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- id: "auth" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.GCP_SA_KEY }}" | |
- name: Configure docker to use the gcloud cli | |
run: gcloud auth configure-docker --quiet | |
- name: Build a docker image | |
run: docker build -t ${{ env.IMAGE }} . | |
- name: Push the docker image | |
run: docker push ${{ env.IMAGE }} | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy $SERVICE_NAME \ | |
--image $IMAGE \ | |
--project $GCP_PROJECT_ID \ | |
--region $GCP_REGION \ | |
--platform=managed \ | |
--allow-unauthenticated \ | |
--quiet \ | |
--set-env-vars=ENV=PRODUCTION \ | |
--set-env-vars=api-key=$API_KEY |