alantech / iasql

Cloud Infrastructure as data in PostgreSQL

Home Page:https://iasql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Periodic check on that the production dashboard is accessible

depombo opened this issue · comments

We use to have the job below that when deploying to staging would run the entire test suite, but it was quite flaky. We could write a smaller integration test that runs periodically in CI and probes the production dashboard

name: Deploy UI to staging

on:
  push:
    branches: [main]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - name: Check out repo
        uses: actions/checkout@v3
      # Node is required for npm
      - name: Set up Node
        uses: actions/setup-node@v2
        with:
          node-version: "16"
      - name: Set CNAME
        run: |
          touch public/CNAME
          echo app-staging.iasql.com >> public/CNAME
      # Install and build website
      - name: Build website
        run: |
          yarn
          yarn install 
          yarn build
        env:
          REACT_APP_IASQL_ENV: staging
      - name: Deploy to GitHub Pages
        if: success()
        uses: crazy-max/ghaction-github-pages@v2
        with:
          target_branch: gh-pages
          build_dir: build
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  sleep:
    runs-on: ubuntu-latest
    needs:
      - publish
    steps:
      - name: sleep
        run: sleep 10

  test:
    timeout-minutes: 20
    runs-on: ubuntu-latest
    needs:
      - sleep
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v2
        with:
          node-version: "16"
      - name: Install dependencies
        run: yarn
      - name: Install Playwright
        run: npx playwright install --with-deps
      - name: Run Playwright tests
        run: yarn playwright test
        env:
          TEST_ACCOUNT_EMAIL: dev+dashboard-testing@iasql.com
          TEST_ACCOUNT_PASSWORD: ${{ secrets.TEST_ACCOUNT_PASSWORD }}
          AWS_REGION: us-east-2
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
          REACT_APP_IASQL_ENV: staging
          WEBSITE_URL: https://app-staging.iasql.com/
      # https://github.com/actions/upload-artifact#where-does-the-upload-go
      # Download artifact and upload to https://trace.playwright.dev
      - uses: actions/upload-artifact@v2
        if: always()
        with:
          name: test-results
          path: test-results/
          retention-days: 7
  notify:
    name: Discord Notification
    runs-on: ubuntu-latest
    needs: # make sure the notification is sent AFTER the jobs you want included have completed
      - publish
      - test
    if: ${{ always() }} # You always want to be notified: success, failure, or cancelled

    steps:
      - name: Notify
        uses: nobrayner/discord-webhook@v1
        with:
          github-token: ${{ secrets.github_token }}
          discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}