ibafly / full-stack-open-blogapp

Full Stack Open part11 exercise 11.20-21

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notes on making blog app work with CI

Blog app is derived from what I made in full stack open part4&5, and CI is operated by Github Actions.

  • Create ./.env file from repo secrets, for dotenv to use:

    - name: Create .env file
      run: |
        echo "TEST_MONGODB_URI = ${{secrets.TEST_MONGODB_URI}}" >> .env

    Remember to add double qoutes as above.

  • Config Cypress options, in my case:

    - name: e2e test
      uses: cypress-io/github-action@v2
      with:
        command: yarn test:e2e -q # -q slims the output
        start: yarn start:test
        wait-on: "http://localhost:3000"
        config: video=false # disable video recording
  • To avoid error spawnSync /bin/sh ENOBUFS thrown when Heroku deploys, remove directory ./node_modules right before deploy:

    - name: remove files
      run: rm ./node_modules -rf

    I don't know why but this way works.

  • Add scripts in husky hooks (e.g. in .husky/precommit or ./package.json), to avoid git commands during Heroku deployment triggering hooks:

    if [[$CI -ne true]]; then # trigger before commit only when environment variable CI is not true
    	yarn lint:fix # eslint auto fix
    fi
    "husky": {
      "hooks": {
        "pre-commit": "if [[$CI -ne true]]; then yarn lint:fix fi"
      }
    }
  • Skip CI when only README file is pushed:

    There are several ways.

    1. Use Github's built-in feature to skip CI on any labeled commits. Include keywords in your commit message like [skip ci], [ci skip], [no ci], [skip actions], or [actions skip].

    2. Ignore specified path in workflow file:

      on:
      push:
      paths-ignore:
        - "README.md"

About

Full Stack Open part11 exercise 11.20-21


Languages

Language:JavaScript 96.9%Language:HTML 2.9%Language:Shell 0.1%Language:Procfile 0.0%