From 7f807a6ed34c616de4b9c0319a8625a0a93dba70 Mon Sep 17 00:00:00 2001 From: Tomachi <8929706+book000@users.noreply.github.com> Date: Sat, 28 Jan 2023 10:08:30 +0900 Subject: [PATCH] ci: reusable workflow ci (#40) --- .github/workflows/add-reviewer.yml | 15 +++++ .github/workflows/hadolint-ci.yml | 9 +-- .github/workflows/nodejs-ci.yml | 91 +----------------------------- 3 files changed, 19 insertions(+), 96 deletions(-) create mode 100644 .github/workflows/add-reviewer.yml diff --git a/.github/workflows/add-reviewer.yml b/.github/workflows/add-reviewer.yml new file mode 100644 index 0000000..15e2e79 --- /dev/null +++ b/.github/workflows/add-reviewer.yml @@ -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 diff --git a/.github/workflows/hadolint-ci.yml b/.github/workflows/hadolint-ci.yml index d51d449..df17d1c 100644 --- a/.github/workflows/hadolint-ci.yml +++ b/.github/workflows/hadolint-ci.yml @@ -12,10 +12,5 @@ on: jobs: hadolint: - runs-on: ubuntu-latest - - steps: - - name: Checkout ๐Ÿ›Ž - uses: actions/checkout@v3 - - - uses: hadolint/hadolint-action@v3.1.0 + name: hadolint + uses: book000/templates/.github/workflows/reusable-hadolint-ci.yml@master diff --git a/.github/workflows/nodejs-ci.yml b/.github/workflows/nodejs-ci.yml index ad506ab..bac5422 100644 --- a/.github/workflows/nodejs-ci.yml +++ b/.github/workflows/nodejs-ci.yml @@ -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