Deploy to Google Cloud #318
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 to Google Cloud | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy-component: | |
description: 'Select the component to deploy' | |
required: true | |
type: choice | |
options: | |
- 'all' | |
- 'app engine' | |
- 'staging website' | |
- 'website' | |
- 'admin' | |
- 'dispatch' | |
- 'functions' | |
- 'archivePurchasedPhotos' | |
- 'compressPublicPhotos' | |
- 'deletePublicPhotos' | |
jobs: | |
Deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Authenticate with Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.DEPLOY_GITHUB_SERV_ACC_KEY }} | |
- name: Setup Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Deploy compressPublicPhotos | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'functions' || github.event.inputs.deploy-component == 'compressPublicPhotos' }} | |
run: | | |
gcloud functions deploy compressPublicPhotos \ | |
--gen2 \ | |
--region=europe-north1 \ | |
--runtime=nodejs20 \ | |
--source=${{ github.workspace }}/functions/compressPublicPhotos \ | |
--entry-point=compressPhoto \ | |
--trigger-event-filters=bucket=${{ secrets.PHOTOS_BUCKET }} \ | |
--trigger-event-filters=type=google.cloud.storage.object.v1.finalized \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--set-env-vars PUBLIC_PHOTOS_BUCKET=${{ secrets.PUBLIC_PHOTOS_BUCKET }} | |
- name: Deploy deletePublicPhotos | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'functions' || github.event.inputs.deploy-component == 'deletePublicPhotos' }} | |
run: | | |
gcloud functions deploy deletePublicPhotos \ | |
--gen2 \ | |
--region=europe-north1 \ | |
--runtime=nodejs20 \ | |
--source=${{ github.workspace }}/functions/deletePublicPhotos \ | |
--entry-point=deletePhoto \ | |
--trigger-event-filters=bucket=${{ secrets.PHOTOS_BUCKET }} \ | |
--trigger-event-filters=type=google.cloud.storage.object.v1.deleted \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--set-env-vars PUBLIC_PHOTOS_BUCKET=${{ secrets.PUBLIC_PHOTOS_BUCKET }} | |
- name: Deploy archivePurchasedPhotos | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'functions' || github.event.inputs.deploy-component == 'archivePurchasedPhotos' }} | |
run: | | |
gcloud functions deploy archivePurchasedPhotos \ | |
--gen2 \ | |
--memory 512MB \ | |
--region=europe-north1 \ | |
--runtime=nodejs20 \ | |
--source=${{ github.workspace }}/functions/archivePurchasedPhotos \ | |
--entry-point=createPhotosArchive \ | |
--trigger-http \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--set-env-vars PHOTOS_BUCKET=${{ secrets.PHOTOS_BUCKET }},ARCHIVE_BUCKET=${{ secrets.ARCHIVE_BUCKET }} \ | |
--service-account=${{ secrets.ARCHIVE_PURCHASED_PHOTOS_SERV_ACC_EMAIL }} \ | |
--timeout=540s | |
- name: Update environment variables for staging website | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'staging website' }} | |
uses: 73h/gae-app-yaml-replace-env-variables@v0.3 | |
env: | |
SERVER_URL: ${{ secrets.TEST_SERVER_URL }} | |
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
REPOSITORY: ${{ secrets.REPOSITORY }} | |
USER_AGENT: ${{ secrets.USER_AGENT }} | |
OWNER: ${{ secrets.OWNER }} | |
ARCHIVE_PURCHASED_PHOTOS_FUNCTION_URL: ${{ secrets.ARCHIVE_PURCHASED_PHOTOS_FUNCTION_URL }} | |
PHOTOS_BUCKET: ${{ secrets.PHOTOS_BUCKET }} | |
PUBLIC_PHOTOS_BUCKET: ${{ secrets.PUBLIC_PHOTOS_BUCKET }} | |
PHOTO_CAROUSEL_BUCKET: ${{ secrets.PHOTO_CAROUSEL_BUCKET }} | |
NATURE_SHOWCASE_BUCKET: ${{ secrets.NATURE_SHOWCASE_BUCKET }} | |
ANIMALS_SHOWCASE_BUCKET: ${{ secrets.ANIMALS_SHOWCASE_BUCKET }} | |
ARCHITECTURAL_SHOWCASE_BUCKET: ${{ secrets.ARCHITECTURAL_SHOWCASE_BUCKET }} | |
PORTRAIT_SHOWCASE_BUCKET: ${{ secrets.PORTRAIT_SHOWCASE_BUCKET }} | |
WEDDING_SHOWCASE_BUCKET: ${{ secrets.WEDDING_SHOWCASE_BUCKET }} | |
SPORT_SHOWCASE_BUCKET: ${{ secrets.SPORT_SHOWCASE_BUCKET }} | |
SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }} | |
WEBHOOK_SECRET: ${{ secrets.TEST_WEBHOOK_SECRET }} | |
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }} | |
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} | |
SUPPORT_EMAIL_ADDRESS: ${{ secrets.DEV_EMAIL_ADDRESS }} | |
DEV_EMAIL_ADDRESS: ${{ secrets.DEV_EMAIL_ADDRESS }} | |
DISABLE_CHECKOUT: ${{ secrets.TEST_DISABLE_CHECKOUT }} | |
with: | |
app_yaml_path: 'website/staging-app.yaml' | |
- name: Deploy staging website | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'staging website' }} | |
run: | | |
gcloud app deploy ${{ github.workspace }}/website/staging-app.yaml \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--version staging-website-v1 | |
- name: Update environment variables for website | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'website' }} | |
uses: 73h/gae-app-yaml-replace-env-variables@v0.3 | |
env: | |
SERVER_URL: ${{ secrets.SERVER_URL }} | |
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
REPOSITORY: ${{ secrets.REPOSITORY }} | |
USER_AGENT: ${{ secrets.USER_AGENT }} | |
OWNER: ${{ secrets.OWNER }} | |
ARCHIVE_PURCHASED_PHOTOS_FUNCTION_URL: ${{ secrets.ARCHIVE_PURCHASED_PHOTOS_FUNCTION_URL }} | |
PHOTOS_BUCKET: ${{ secrets.PHOTOS_BUCKET }} | |
PUBLIC_PHOTOS_BUCKET: ${{ secrets.PUBLIC_PHOTOS_BUCKET }} | |
PHOTO_CAROUSEL_BUCKET: ${{ secrets.PHOTO_CAROUSEL_BUCKET }} | |
NATURE_SHOWCASE_BUCKET: ${{ secrets.NATURE_SHOWCASE_BUCKET }} | |
ANIMALS_SHOWCASE_BUCKET: ${{ secrets.ANIMALS_SHOWCASE_BUCKET }} | |
ARCHITECTURAL_SHOWCASE_BUCKET: ${{ secrets.ARCHITECTURAL_SHOWCASE_BUCKET }} | |
PORTRAIT_SHOWCASE_BUCKET: ${{ secrets.PORTRAIT_SHOWCASE_BUCKET }} | |
WEDDING_SHOWCASE_BUCKET: ${{ secrets.WEDDING_SHOWCASE_BUCKET }} | |
SPORT_SHOWCASE_BUCKET: ${{ secrets.SPORT_SHOWCASE_BUCKET }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }} | |
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }} | |
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} | |
SUPPORT_EMAIL_ADDRESS: ${{ secrets.SUPPORT_EMAIL_ADDRESS }} | |
DEV_EMAIL_ADDRESS: ${{ secrets.DEV_EMAIL_ADDRESS }} | |
DISABLE_CHECKOUT: ${{ secrets.DISABLE_CHECKOUT }} | |
with: | |
app_yaml_path: 'website/app.yaml' | |
- name: Deploy website | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'website' }} | |
run: | | |
gcloud app deploy ${{ github.workspace }}/website/app.yaml \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--version website-v1 | |
- name: Update environment variables for admin panel | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'admin' }} | |
uses: 73h/gae-app-yaml-replace-env-variables@v0.3 | |
env: | |
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }} | |
SESSION_SECRET: ${{ secrets.SESSION_SECRET }} | |
SERVE_ONLY_HTTPS: ${{ secrets.SERVE_ONLY_HTTPS }} | |
PHOTOS_BUCKET: ${{ secrets.PHOTOS_BUCKET }} | |
PUBLIC_PHOTOS_BUCKET: ${{ secrets.PUBLIC_PHOTOS_BUCKET }} | |
PHOTO_CAROUSEL_BUCKET: ${{ secrets.PHOTO_CAROUSEL_BUCKET }} | |
NATURE_SHOWCASE_BUCKET: ${{ secrets.NATURE_SHOWCASE_BUCKET }} | |
ANIMALS_SHOWCASE_BUCKET: ${{ secrets.ANIMALS_SHOWCASE_BUCKET }} | |
ARCHITECTURAL_SHOWCASE_BUCKET: ${{ secrets.ARCHITECTURAL_SHOWCASE_BUCKET }} | |
PORTRAIT_SHOWCASE_BUCKET: ${{ secrets.PORTRAIT_SHOWCASE_BUCKET }} | |
WEDDING_SHOWCASE_BUCKET: ${{ secrets.WEDDING_SHOWCASE_BUCKET }} | |
SPORT_SHOWCASE_BUCKET: ${{ secrets.SPORT_SHOWCASE_BUCKET }} | |
with: | |
app_yaml_path: 'admin/app.yaml' | |
- name: Deploy admin panel | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'admin' }} | |
run: | | |
gcloud app deploy ${{ github.workspace }}/admin/app.yaml \ | |
--project=${{ secrets.PROJECT_ID }} \ | |
--version admin-v1 | |
- name: Deploy dispatch | |
if: ${{ github.event.inputs.deploy-component == 'all' || github.event.inputs.deploy-component == 'app engine' || github.event.inputs.deploy-component == 'dispatch' }} | |
run: | | |
gcloud app deploy dispatch.yaml \ | |
--project=${{ secrets.PROJECT_ID }} |