Skip to content

Commit

Permalink
build(ci): add ci (#384)
Browse files Browse the repository at this point in the history
* build(ci): add ci!

* build(package): add missing commands

* fix(ci): removed extra build job
  • Loading branch information
seaerchin authored Mar 31, 2022
1 parent 5c3a3be commit 8df61bc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,78 @@
name: ci

on:
push:
pull_request:
types: [opened, reopened]

env:
PRODUCTION_BRANCH: refs/heads/master
STAGING_BRANCH: refs/heads/staging
EB_APP: isomer-cms
EB_ENV_PRODUCTION: cms-backend-prod
EB_ENV_STAGING: cms-backend-staging
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}

jobs:
install:
# NOTE: Netlify uses ubuntu 16.08 but Github Actions does not offer it by default.
# Hence, we default to the latest version.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: npm ci

lint:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Load Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run lint-fix
- run: npm run format-fix

test:
needs: lint
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Load Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run test

gatekeep:
name: Determine if Build & Deploy is needed
outputs:
Expand All @@ -29,6 +91,7 @@ jobs:
print('::set-output name=proceed::true')
else:
print('::set-output name=proceed::false')
deploy:
name: Build and deploy to EB
runs-on: ubuntu-18.04
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"test": "source .env.test && jest",
"release": "npm version $npm_config_isomer_update && git push --tags",
"lint": "npx eslint .",
"format": "npx prettier --write .",
"check-format": "npx prettier --check .",
"lint-fix": "eslint --ignore-path .gitignore . --fix",
"format": "npx prettier --check .",
"format-fix": "npx prettier --write .",
"prepare": "husky install",
"version": "auto-changelog -p && git add CHANGELOG.md"
},
Expand Down

0 comments on commit 8df61bc

Please sign in to comment.