Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
ci: reusable workflow ci (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jan 28, 2023
1 parent 46cc609 commit 7f807a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 96 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/add-reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Auto add reviewer

on:
pull_request_target:
types:
- opened
- reopened
branches:
- main
- master

jobs:
add-reviewer:
name: Add reviewer
uses: book000/templates/.github/workflows/reusable-add-reviewer.yml@master
9 changes: 2 additions & 7 deletions .github/workflows/hadolint-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,5 @@ on:

jobs:
hadolint:
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎
uses: actions/checkout@v3

- uses: hadolint/[email protected]
name: hadolint
uses: book000/templates/.github/workflows/reusable-hadolint-ci.yml@master
91 changes: 2 additions & 89 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,92 +14,5 @@ on:

jobs:
node-ci:
runs-on: ubuntu-latest

steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: 🏗 Setup node
uses: actions/setup-node@v3
with:
node-version-file: .node-version
cache: yarn

- name: 📃 Check package.json definition
id: package-json
run: |
compile=$(jq '.scripts | has("compile")' package.json)
build=$(jq '.scripts | has("build")' package.json)
generate=$(jq '.scripts | has("generate")' package.json)
package=$(jq '.scripts | has("package")' package.json)
lint=$(jq '.scripts | has("lint")' package.json)
test=$(jq '.scripts | has("test")' package.json)
echo "compile: $compile"
echo "build: $build"
echo "generate: $generate"
echo "package: $package"
echo "lint: $lint"
echo "test: $test"
echo "compile=$compile" >> $GITHUB_OUTPUT
echo "build=$build" >> $GITHUB_OUTPUT
echo "generate=$generate" >> $GITHUB_OUTPUT
echo "package=$package" >> $GITHUB_OUTPUT
echo "lint=$lint" >> $GITHUB_OUTPUT
echo "test=$test" >> $GITHUB_OUTPUT
- name: 👨🏻‍💻 Install dependencies
run: yarn install --frozen-lockfile

- name: 👀 Run linter
if: steps.package-json.outputs.lint == 'true'
run: yarn lint

- name: 🎁 Run package
if: steps.package-json.outputs.package == 'true'
run: yarn package

- name: 🏃 Run compile
if: steps.package-json.outputs.compile == 'true'
run: yarn compile

- name: 🏗️ Run build & generate (Nuxt.js)
if: steps.package-json.outputs.build == 'true' && steps.package-json.outputs.generate == 'true'
run: |
yarn build
yarn generate
- name: 🧪 Run tests
if: steps.package-json.outputs.test == 'true'
run: yarn test

- name: ☑️ Check Dependencies
run: npx depcheck

- name: Check exists dist directory
id: check-dist
run: |
echo "exists=$(test -d dist && echo true || echo false)" >> $GITHUB_OUTPUT
- name: 📦 Upload dist artifact
if: steps.check-dist.outputs.exists == 'true'
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

- name: Check exists output directory
id: check-output
run: |
echo "exists=$(test -d output && echo true || echo false)" >> $GITHUB_OUTPUT
- name: 📦 Upload output artifact
if: steps.check-output.outputs.exists == 'true'
uses: actions/upload-artifact@v3
with:
name: output
path: output
name: Node CI
uses: book000/templates/.github/workflows/reusable-nodejs-ci.yml@master

0 comments on commit 7f807a6

Please sign in to comment.