Skip to content

Commit

Permalink
ci: separate deploy from release
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Oct 8, 2024
1 parent 11d1289 commit d1214e3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 85 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Pull Request Events

on: pull_request

permissions:
Expand Down Expand Up @@ -44,31 +45,24 @@ jobs:
run: npm run test:ci

deploy-preview:
name: Firebase preview
name: Create 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
name: preview

steps:
- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
build-command: npm run build
preview: yes
build-command: npm run build -- --mode dev
project-id: ${{ secrets.PROJECT_ID }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_DATABASE_URL: ${{ secrets.VITE_FIREBASE_DATABASE_URL }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APPID: ${{ secrets.VITE_FIREBASE_APPID }}
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.VITE_FIREBASE_MEASUREMENT_ID }}
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
VITE_API_KEY: ${{ secrets.VITE_UGRC_API_KEY }}
VITE_DISCOVER_KEY: ${{ secrets.VITE_DISCOVER_KEY }}
VITE_API_KEY_PREVIEW: ${{ secrets.VITE_UGRC_PREVIEW_API_KEY }}
76 changes: 4 additions & 72 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
name: Push Events

on:
push:
branches:
- main
- dev

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -19,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 @@ -33,67 +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 dev
runs-on: ubuntu-latest
needs: release-please
environment:
name: dev
url: https://plss.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:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
build-command: npm run build
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_DATABASE_URL: ${{ secrets.VITE_FIREBASE_DATABASE_URL }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APPID: ${{ secrets.VITE_FIREBASE_APPID }}
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.VITE_FIREBASE_MEASUREMENT_ID }}
VITE_DISCOVER_KEY: ${{ secrets.VITE_DISCOVER_KEY }}
VITE_API_KEY: ${{ secrets.VITE_UGRC_API_KEY }}

deploy-prod:
name: Deploy to production
runs-on: ubuntu-latest
needs: release-please
environment:
name: prod
url: https://plss.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:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
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 }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
build-command: npm run build
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_DATABASE_URL: ${{ secrets.VITE_FIREBASE_DATABASE_URL }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APPID: ${{ secrets.VITE_FIREBASE_APPID }}
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.VITE_FIREBASE_MEASUREMENT_ID }}
VITE_DISCOVER_KEY: ${{ secrets.VITE_DISCOVER_KEY }}
VITE_API_KEY: ${{ secrets.VITE_UGRC_API_KEY }}
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Release Events

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

permissions:
id-token: write
deployments: write

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

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
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
VITE_DISCOVER_KEY: ${{ secrets.VITE_DISCOVER_KEY }}
VITE_API_KEY: ${{ secrets.VITE_UGRC_API_KEY }}

deploy-prod:
name: Deploy to production
runs-on: ubuntu-latest
environment:
name: prod
url: https://plss.utah.gov
if: github.event.release.prerelease == false

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 }}
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 }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
build-command: npm run build
env:
VITE_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
VITE_DISCOVER_KEY: ${{ secrets.VITE_DISCOVER_KEY }}
VITE_API_KEY: ${{ secrets.VITE_UGRC_API_KEY }}

0 comments on commit d1214e3

Please sign in to comment.