diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5315921..00a9977 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,4 +1,5 @@ name: Pull Request Events + on: pull_request permissions: @@ -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 }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d8ac887..301be2b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bcb1e20 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }}