Skip to content

Commit

Permalink
refactor: split release from deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Oct 2, 2024
1 parent c70153c commit deeeb98
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 80 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: Firebase preview
runs-on: ubuntu-latest
needs: [test-unit]
if: ${{ github.event.sender.type == 'User' }}
if: ${{ github.event.sender.type == 'User' && github.head_ref != 'dev' }}
environment:
name: dev

Expand All @@ -54,3 +54,5 @@ jobs:
project-id: ${{ secrets.PROJECT_ID }}
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
82 changes: 3 additions & 79 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ on:
- dev
- main

permissions:
contents: write
id-token: write
deployments: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -20,8 +14,9 @@ jobs:
release-please:
name: Create release
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
permissions:
contents: write
pull-requests: write

steps:
- name: 🚀 Create Release
Expand All @@ -34,74 +29,3 @@ jobs:
github-app-key: ${{ secrets.UGRC_RELEASE_BOT_APP_KEY }}
github-app-name: ${{ secrets.UGRC_RELEASE_BOT_NAME }}
github-app-email: ${{ secrets.UGRC_RELEASE_BOT_EMAIL }}

deploy-dev:
name: Deploy to staging
runs-on: ubuntu-latest
needs: release-please
environment:
name: dev
url: https://chalkdust.dev.utah.gov
if: github.ref_name == 'dev' && needs.release-please.outputs.release_created

steps:
- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
build-command: npm run build -- --mode dev
repo-token: ${{ secrets.GITHUB_TOKEN }}
project-id: ${{ secrets.PROJECT_ID }}
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}

- name: 🚀 Deploy Cloud Function
uses: google-github-actions/deploy-cloud-functions@v2
with:
name: send-email-service
runtime: nodejs20
source_dir: function
entry_point: sendgrid
timeout: 10
max_instances: 2
min_instances: 0
memory_mb: 128
secret_environment_variables: 'SENDGRID_API_KEY=projects/${{ secrets.PROJECT_ID }}/secrets/sendgrid'
service_account_email: function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com

deploy-prod:
name: Deploy to production
runs-on: ubuntu-latest
needs: release-please
environment:
name: prod
url: https://chalkdust.ugrc.utah.gov
if: github.ref_name == 'main' && needs.release-please.outputs.release_created

steps:
- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
build-command: npm run build -- --mode production
repo-token: ${{ secrets.GITHUB_TOKEN }}
project-id: ${{ secrets.PROJECT_ID }}
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
service-now-instance: ${{ secrets.SN_INSTANCE }}
service-now-table: ${{ secrets.SN_TABLE }}
service-now-system-id: ${{ secrets.SN_SYS_ID }}
service-now-username: ${{ secrets.SN_USERNAME }}
service-now-password: ${{ secrets.SN_PASSWORD }}

- name: 🚀 Deploy Cloud Function
uses: google-github-actions/deploy-cloud-functions@v2
with:
name: send-email-service
runtime: nodejs20
source_dir: function
entry_point: sendgrid
timeout: 10
max_instances: 2
min_instances: 0
memory_mb: 128
secret_environment_variables: 'SENDGRID_API_KEY=projects/${{ secrets.PROJECT_ID }}/secrets/sendgrid'
service_account_email: function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com
73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release Events

on:
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
type: environment
required: true

jobs:
deploy-dev:
name: Deploy to staging
runs-on: ubuntu-latest
environment:
name: dev
url: https://atlas.dev.utah.gov
if: github.event.release.prerelease == true || inputs.environment == 'dev'

steps:
- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
build-command: npm run build -- --mode dev
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}

deploy-prod:
name: Deploy to production
runs-on: ubuntu-latest
permissions:
id-token: write
deployments: write
environment:
name: prod
url: https://chalkdust.ugrc.utah.gov
if: github.event.release.prerelease == false || inputs.environment == 'prod'

steps:
- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
build-command: npm run build -- --mode production
repo-token: ${{ secrets.GITHUB_TOKEN }}
project-id: ${{ secrets.PROJECT_ID }}
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
service-now-instance: ${{ secrets.SN_INSTANCE }}
service-now-table: ${{ secrets.SN_TABLE }}
service-now-system-id: ${{ secrets.SN_SYS_ID }}
service-now-username: ${{ secrets.SN_USERNAME }}
service-now-password: ${{ secrets.SN_PASSWORD }}
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}

- name: 🚀 Deploy Cloud Function
uses: google-github-actions/deploy-cloud-functions@v2
with:
name: send-email-service
runtime: nodejs20
source_dir: function
entry_point: sendgrid
timeout: 10
max_instances: 2
min_instances: 0
memory_mb: 128
secret_environment_variables: 'SENDGRID_API_KEY=projects/${{ secrets.PROJECT_ID }}/secrets/sendgrid'
service_account_email: function-sa@${{ secrets.PROJECT_ID }}.iam.gserviceaccount.com

0 comments on commit deeeb98

Please sign in to comment.