mavend/octoboard

View on GitHub
.github/workflows/master.yml

Summary

Maintainability
Test Coverage
name: Deploy Production to octoboard

on:
  push:
    branches: [master]
    tags:
      - "!*" # Do not execute on tags

jobs:
  deploy_server:
    name: Deploy server
    runs-on: ubuntu-latest
    environment:
      name: octoboard-server
      url: https://api.octoboards.com/
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up SSH
        run: |
          mkdir -p ~/.ssh/
          echo "$SSH_PRIVATE_KEY" > ./deploy.key
          sudo chmod 600 ./deploy.key
          echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
        shell: bash
        env:
          SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
          SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
      - name: Create env file
        run: |
          touch .env
          echo PRODUCTION_HOST=${{ secrets.PRODUCTION_HOST }} >> .env
          echo SENTRY_DSN=${{ secrets.APP_SENTRY_DSN }} >> .env
      - name: Install pm2
        run: npm ci
      - name: Deploy
        run: env $(cat .env | grep -v \"#\" | xargs) npm run deploy
  deploy_client:
    name: Deploy client
    runs-on: ubuntu-latest
    needs: deploy_server
    environment:
      name: octoboard-client
      url: https://octoboards.com/
    env:
      REACT_APP_API_ROOT: https://api.octoboards.com
      REACT_APP_SENTRY_DSN: ${{ secrets.REACT_APP_SENTRY_DSN }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Build
        run: npm ci && npm run build
      - name: Deploy
        uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: "${{ secrets.GITHUB_TOKEN }}"
          firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_OCTO_BOARD }}"
          channelId: live
          projectId: octo-board
        env:
          FIREBASE_CLI_PREVIEWS: hostingchannels