chore: Update develop.deploy-functions.yml to conditionally set environment variables and authenticate with Google Cloud

This commit is contained in:
Josh Furie 2024-07-20 12:12:50 -07:00
parent 6f0b8a83db
commit 5b954fe7f8

View File

@ -30,10 +30,12 @@ jobs:
with: with:
persist-credentials: false persist-credentials: false
- name: Semantic Release - name: Semantic Release
id: semantic
uses: cycjimmy/semantic-release-action@v4 uses: cycjimmy/semantic-release-action@v4
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Set Environment Variables - name: Set Environment Variables
if: steps.semantic.outputs.new_release_published == 'true'
run: | run: |
echo COMPANY_NAME="${{ env.COMPANY_NAME }}" > .env echo COMPANY_NAME="${{ env.COMPANY_NAME }}" > .env
echo TWITTER_CREATOR="${{ env.TWITTER_CREATOR }}" >> .env echo TWITTER_CREATOR="${{ env.TWITTER_CREATOR }}" >> .env
@ -44,24 +46,29 @@ jobs:
echo SHOPIFY_STORE_DOMAIN="${{ env.SHOPIFY_STORE_DOMAIN }}" >> .env echo SHOPIFY_STORE_DOMAIN="${{ env.SHOPIFY_STORE_DOMAIN }}" >> .env
- name: Authenticate with Google Cloud - name: Authenticate with Google Cloud
if: steps.semantic.outputs.new_release_published == 'true'
id: auth id: auth
uses: google-github-actions/auth@v2 uses: google-github-actions/auth@v2
with: with:
project_id: ${{ vars.PROJECT_ID }} project_id: ${{ vars.PROJECT_ID }}
credentials_json: ${{secrets.CREDENTIALS_JSON}} credentials_json: ${{secrets.CREDENTIALS_JSON}}
- name: Set up Cloud SDK - name: Set up Cloud SDK
if: steps.semantic.outputs.new_release_published == 'true'
uses: 'google-github-actions/setup-gcloud@v2' uses: 'google-github-actions/setup-gcloud@v2'
- name: Configure Docker - name: Configure Docker
if: steps.semantic.outputs.new_release_published == 'true'
run: | run: |
gcloud auth configure-docker gcloud auth configure-docker
- name: Build and Push Docker Image - name: Build and Push Docker Image
if: steps.semantic.outputs.new_release_published == 'true'
run: | run: |
docker build -t gcr.io/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_IMAGE_NAME }}:latest . docker build -t gcr.io/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_IMAGE_NAME }}:latest .
docker push gcr.io/${{ vars.PROJECT_ID}}/${{ vars.DOCKER_IMAGE_NAME }}:latest docker push gcr.io/${{ vars.PROJECT_ID}}/${{ vars.DOCKER_IMAGE_NAME }}:latest
- name: Deploy to Cloud Run - name: Deploy to Cloud Run
if: steps.semantic.outputs.new_release_published == 'true'
run: | run: |
gcloud run deploy ${{vars.APP_NAME}} \ gcloud run deploy ${{vars.APP_NAME}} \
--image gcr.io/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_IMAGE_NAME }}:latest \ --image gcr.io/${{ vars.PROJECT_ID }}/${{ vars.DOCKER_IMAGE_NAME }}:latest \