Skip to content

Commit

Permalink
chore(actions): add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukaato committed Aug 2, 2024
1 parent 897458d commit 0588160
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 25 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI
name: Build

on:
workflow_call:
push:
branches: [ "main" ]
paths-ignore:
- '.github/**'
- '.husky/**'
- 'assets/**'
branches:
- main
- develop
- 'feat/**'
- 'fix/**'
pull_request:
branches: [ "main" ]
branches:
- main
- develop

jobs:
build:
Expand All @@ -26,7 +37,18 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run format
- run: npm run lint
- run: npm run build --if-present

- name: Install
run: npm ci

- name: Audit
run: npx audit-ci@latest --config ./audit-ci.json

- name: Prettier
run: npm run format

- name: Lint
run: npm run lint

- name: Build
run: npm run build --if-present
17 changes: 13 additions & 4 deletions .github/workflows/code-smell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ name: Code smell

on:
push:
branches: [ "main" ]
paths-ignore:
- '.github/**'
- '.husky/**'
- 'assets/**'
branches:
- main
- develop
- 'feat/**'
- 'fix/**'
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches:
- main
- develop
schedule:
- cron: '22 21 * * 6'

Expand All @@ -22,12 +31,12 @@ permissions:

jobs:
njsscan:
name: Code scanning
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
name: njsscan code scanning
steps:
- name: Checkout the code
uses: actions/checkout@v4
Expand Down
32 changes: 20 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,41 @@ on:

jobs:
build:
uses: ./build.yml
uses: ./.github/workflows/build.yml

version:
needs: build
runs-on: ubuntu-latest
name: Update version in package.json
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- uses: actions/checkout@v4

- name: Show version
run: cat ./package.json | grep version

- name: Bump version (patch)
- name: Bump version
id: version
uses: KageKirin/[email protected]
with:
major: ${{ github.event.inputs.version }} == major
minor: ${{ github.event.inputs.version }} == minor
patch: ${{ github.event.inputs.version }} == patch
major: ${{ github.event.inputs.version == 'major' }}
minor: ${{ github.event.inputs.version == 'minor' }}
patch: ${{ github.event.inputs.version == 'patch' }}

- name: Show updated version
run: cat ./package.json | grep version

- name: Commit new version
run: |
git commit -am "ci(version): bump version to ${{ steps.test.package_version.version }}"
git tag -m "ci(version): create new tag" v${{ steps.test.package_version.version }}
git push --follow-tags https://${{ github.token }}@github.com/${{ github.repository }}

- name: Commit & tag version
uses: EndBug/add-and-commit@v9
with:
author_name: cheese_grinder_ci
author_email: [email protected]
committer_name: cheese_grinder_ci
committer_email: [email protected]
message: "ci(version): bump to ${{ steps.version.outputs.version }}"
tag: "v${{ steps.version.outputs.version }}"

publish-npm:
needs: version
Expand All @@ -60,4 +68,4 @@ jobs:
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint:commit -- --edit
npx commitlint --edit
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"format:fix": "prettier ./src/**/*.ts --write",
"lint": "eslint \"src/**/*.ts\"",
"lint:fix": "eslint \"src/**/*.ts\" --fix",
"lint:commit": "commitlint",
"prepare": "husky"
},
"main": "dist/index.js",
Expand Down

0 comments on commit 0588160

Please sign in to comment.