asuc-octo / berkeleytime

UC Berkeley enrollment info
https://berkeleytime.com
MIT License
56 stars 9 forks source link

[core eng] modern CICD #723

Closed maxmwang closed 1 month ago

maxmwang commented 2 months ago

Primarily building off @Chengming-Li great work on testCICD.

This PR introduces CICD workflows via Github Actions for:

Manually triggered workflows use the workflow dispatch trigger. To trigger these, go into the "Actions" tab, select the correct action on the left panel, then click "Run workflow".

The development workflow also initiates a pod that cleans up the dev install after a certain amount of seconds, inputted from engineers when first running the dev workflow. There is no enforced cap, but please keep this number small.

mathhulk commented 2 months ago

I'd strongly recommend using reusable workflows when you have multiple workflows which do practically the same thing:

cd.yaml

name: Deploy

on:
  workflow_call:
    inputs:
      environment:
        type: string
        required: true
      ...

# All examples
env:
  GKE_CLUSTER: main-cluster
  GKE_ZONE: us-central1-c
  VAR_TAG: ${{ format('tag-{0}', inputs.environment) }}
  ...

jobs:
  deploy:
    name: Build and Deploy
    runs-on: ubuntu-latest-m

    steps:
      ...

cd-prod.yaml

name: Deploy to Production

on:
  workflow_dispatch:
  push:
    branches: ["main"]
    paths: ["apps/*"]

jobs:
  deploy:
    uses: ./.github/workflows/cd.yaml
    secrets: inherit
    with:
      environment: prod
      ...