William Nemenchainitial commit
86fb32e9/11/2022, 1:13:39 AM
.yml
YAML
(text/x-yaml)
name: main
on:
  push:
    branches:
      - main

jobs:
  ci-main:
    name: "🏗 Continuous Integration"
    runs-on: ubuntu-latest
    steps:
      - name: "⚙️ Checkout repository"
        uses: actions/checkout@v3
      - name: "⚙️ Setup Node.JS (16.x)"
        uses: actions/setup-node@v3
        with:
          node-version: "16.x"
      - name: "⚙️ Get Yarn cache folder path"
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: "⚙️ Cache Yarn cache folder"
        uses: actions/cache@v3
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: "⚙️ Cache node_modules folder"
        uses: actions/cache@v3
        id: node-modules-cache # use this to check for `cache-hit` (`steps.node-modules-cache.outputs.cache-hit != 'true'`)
        with:
          path: node_modules
          key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
      - name: "⚙️ Install dependencies via yarn"
        if: |
          steps.yarn-cache.outputs.cache-hit != 'true' ||
          steps.node-modules-cache.outputs.cache-hit != 'true'
        run: "yarn"
      - name: "🔩 Type check & build code"
        run: "yarn build"

  cd-main:
    name: "🚀 Continuous Deployment"
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && github.ref == 'refs/heads/main' # Only deploy main
    needs: ci-main
    steps:
      - name: "⚙️ Checkout repository"
        uses: actions/checkout@v3
      - name: "⚙️ Setup Node.JS (16.x)"
        uses: actions/setup-node@v3
        with:
          node-version: "16.x"
      - name: "▶️ Start Deployment"
        uses: bobheadxi/deployments@v0.4.3
        id: deployment
        with:
          step: start
          token: ${{ secrets.GITHUB_TOKEN }}
          env: "main"
      - name: "🚀 Deploy to production!"
        run: |
          npx --yes exoframe deploy \
            --update \
            --endpoint "${{ secrets.DEPLOY_ENDPOINT }}" \
            --token "${{ secrets.DEPLOY_TOKEN }}"
      - name: "✅ Update Deployment Status"
        uses: bobheadxi/deployments@v0.4.3
        if: always()
        with:
          step: finish
          token: ${{ secrets.GITHUB_TOKEN }}
          status: ${{ job.status }}
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          env_url: "https://react-monolith.ethicdevs.com"