diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 00000000..b2aaa93a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,13 @@ +## Description + +## Test Plan + + + +## Issues + + + +- Closes # + + diff --git a/.github/actions/setup-node-and-pnpm/action.yml b/.github/actions/setup-node-and-pnpm/action.yml new file mode 100644 index 00000000..0bd4124a --- /dev/null +++ b/.github/actions/setup-node-and-pnpm/action.yml @@ -0,0 +1,32 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-action.json +--- +name: Setup Node.js and pnpm + +description: Sets up Node.js and pnpm + pnpm cache. Does **not** install dependencies. + +runs: + using: composite + + steps: + - name: Setup Node.js environment + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4 + with: + node-version: lts/hydrogen + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - name: Setup pnpm cache + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: ${{ runner.os }}-pnpm-store- diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml new file mode 100644 index 00000000..4678d4a6 --- /dev/null +++ b/.github/workflows/deploy-prod.yml @@ -0,0 +1,47 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json +--- +name: Deploy to production + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + id-token: write + contents: read + deployments: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }} + DATABASE_URL: ${{ secrets.PROD_DB_URL }} + MIGRATION_DB_URL: ${{ secrets.MIGRATION_DB_URL }} + +jobs: + deploy: + runs-on: ubuntu-latest + + environment: + name: production + url: https://zotmeet.com + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-and-pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Deploy ZotMeet to production + run: STAGE=prod pnpm db:migrate && pnpm sst deploy --stage prod diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 00000000..49e8f0c7 --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json +--- +name: Deploy to staging + +on: + pull_request: + types: + - opened + - synchronize + - unlabeled + +permissions: + id-token: write + contents: read + deployments: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }} + DATABASE_URL: ${{ secrets.DEV_DB_URL }} + PR_NUM: ${{ github.event.pull_request.number }} + MIGRATION_DB_URL: ${{ secrets.MIGRATION_DB_URL }} + +jobs: + deploy: + if: (!contains(github.event.pull_request.labels.*.name, 'no deploy')) + + runs-on: ubuntu-latest + + environment: + name: staging-${{ github.event.pull_request.number }} + url: https://staging-${{ github.event.pull_request.number }}.zotmeet.com + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-and-pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Deploy ZotMeet to staging + run: pnpm db:migrate && pnpm sst deploy --stage staging-$PR_NUM diff --git a/.github/workflows/destroy-staging.yml b/.github/workflows/destroy-staging.yml new file mode 100644 index 00000000..cc3070b9 --- /dev/null +++ b/.github/workflows/destroy-staging.yml @@ -0,0 +1,56 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json +--- +name: Destroy staging build + +on: + pull_request: + types: + - closed + - labeled + +permissions: + id-token: write + contents: read + deployments: write + pull-requests: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }} + DATABASE_URL: ${{ secrets.DEV_DB_URL }} + PR_NUM: ${{ github.event.pull_request.number }} + +jobs: + destroy: + if: (github.event.action == 'labeled' && github.event.label.name == 'no deploy') || github.event.action == 'closed' + + runs-on: ubuntu-latest + + environment: + name: staging-${{ github.event.pull_request.number }} + url: https://staging-${{ github.event.pull_request.number }}.zotmeet.com + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js and pnpm + uses: ./.github/actions/setup-node-and-pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Destroy ZotMeet staging build + run: pnpm sst remove --stage staging-$PR_NUM + + - name: Set ZotMeet staging environment to inactive + uses: strumwolf/delete-deployment-environment@v2.3.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + environment: staging-${{ github.event.pull_request.number }} + onlyDeactivateDeployments: true