Skip to content

Commit

Permalink
ci: bring actions up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Oct 5, 2022
1 parent 25365f3 commit 3a400c4
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Pull Request Events

on: pull_request

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

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test-unit:
name: Unit tests
runs-on: ubuntu-latest

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v3

- name: βŽ” Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm

- name: πŸ“₯ Download dependencies
run: npm ci

- name: 🧹 Lint
run: npm run lint

- name: πŸ§ͺ Run tests
run: npm test

deploy-preview:
name: Firebase preview
runs-on: ubuntu-latest
needs: test-unit
if: ${{ github.event.sender.type == 'User' }}
environment:
name: 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 }}
preview: yes
build-command: npm run build:stage
repo-token: ${{ secrets.GITHUB_TOKEN }}
110 changes: 110 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Push Events

on:
push:
branches:
- dev
- main

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

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-please:
name: Create release
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}

steps:
- name: πŸš€ Create Release
id: release-please
uses: agrc/release-composite-action@v1
with:
prerelease: ${{ github.ref_name == 'dev' }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
github-app-id: ${{ secrets.UGRC_RELEASE_BOT_APP_ID }}
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 }}

rebuild-docs:
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.release_created
steps:
- name: ⬇️ Checkout Code
uses: actions/checkout@v3

- name: βŽ” Setup Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm

- name: πŸ“₯ Download dependencies
run: npm ci

- name: πŸ“š Update Config Docs
run: npm run update-config-docs

- name: πŸš€ Commit changes
uses: EndBug/add-and-commit@v9
with:
add: 'docs'
message: 'docs: update config docs'

deploy-dev:
name: Deploy to staging
runs-on: ubuntu-latest
needs: release-please
environment:
name: dev
url: https://wfrc-rtp.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:stage
repo-token: ${{ secrets.GITHUB_TOKEN }}

deploy-prod:
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.release_created
steps:
- name: ⬇️ Set up code
uses: actions/checkout@v3

- name: βŽ” Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
cache: npm

- name: πŸ“₯ Download dependencies
run: npm ci

- name: πŸ— Run build
run: npm run build

- name: πŸ—œ Compress
run: npm run zip

- name: πŸš€ Create release
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ needs.release-please.outputs.tag_name }}
file: build.zip

0 comments on commit 3a400c4

Please sign in to comment.