post commit CI #376
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: post commit CI | |
on: | |
push: | |
paths: | |
- scripts/**/*.js | |
- "!scripts/test/*.js" | |
- "!scripts/generateUnrecognizableFeatures/*.js" | |
- "!scripts/detectHardcodedOutdatedNPMPackages/*.js" | |
- "!scripts/autoAssign/*.js" | |
- src/**/*.js | |
- src/**/*.css | |
- src/**/definition.yaml | |
- src/gadgets/Gadgets-definition-list.yaml | |
- .github/workflows/postCommit.yaml | |
- .vscode/json-schemas/gadget-definition.json | |
- .browserslistrc | |
- .*.yaml | |
- package-lock.json | |
merge_group: | |
pull_request: | |
paths: | |
- scripts/**/*.js | |
- "!scripts/test/*.js" | |
- "!scripts/generateUnrecognizableFeatures/*.js" | |
- "!scripts/detectHardcodedOutdatedNPMPackages/*.js" | |
- "!scripts/autoAssign/*.js" | |
- src/**/*.js | |
- src/**/*.css | |
- src/**/definition.yaml | |
- src/gadgets/Gadgets-definition-list.yaml | |
- .github/workflows/postCommit.yaml | |
- .vscode/json-schemas/gadget-definition.json | |
- .browserslistrc | |
- .*.yaml | |
- package-lock.json | |
workflow_dispatch: | |
inputs: | |
manuallyLinterTest: | |
description: 如需手动触发格式检查,请选择上方 Branch 为 master,下方为 true | |
type: choice | |
default: "false" | |
options: | |
- "true" | |
- "false" | |
schedule: | |
- cron: 0 23 * * * # Every 07:00 CST | |
concurrency: | |
group: ${{ github.workflow_ref }}-${{ github.ref }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
actions: read | |
checks: read | |
contents: write | |
deployments: read | |
issues: write | |
discussions: read | |
packages: read | |
pages: read | |
pull-requests: read | |
repository-projects: read | |
security-events: write | |
statuses: write | |
jobs: | |
skipCI: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash | |
id: version | |
shell: bash | |
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v3 | |
name: Try to restore node_modules from cache | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Install dependencies if no cache for node_modules | |
run: npm run ci | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
- uses: actions/cache/save@v3 | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
name: Save node_modules to cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: If needs to skip, skip now | |
run: node scripts/skip/index.js | |
id: skip | |
outputs: | |
skip: ${{ steps.skip.outputs.skip }} | |
postCommit: | |
runs-on: ubuntu-latest | |
needs: | |
- skipCI | |
if: success() && needs.skipCI.outputs.skip != 'true' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash | |
id: version | |
shell: bash | |
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v3 | |
name: Try to restore node_modules from cache | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Install dependencies if no cache for node_modules | |
run: npm run ci | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
- uses: actions/cache/save@v3 | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
name: Save node_modules to cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Git config | |
run: node scripts/postCommit/prepareGit.js | |
- name: Expose GitHub Runtime | |
uses: crazy-max/ghaction-github-runtime@v2 | |
- name: Auto browserify generator | |
run: node scripts/browserify/index.js | |
- name: Auto prefetch | |
run: node scripts/prefetch/index.js | |
- name: Gadget-polyfill generator | |
run: node scripts/generatePolyfill/index.js | |
- name: Gadgets-definition Generator | |
run: node scripts/generateGadgetsDefinition/index.js | |
- name: Conventional Commits scopes generator | |
run: node scripts/generateConventionalCommitsScopes/index.js | |
- name: Commits History generator | |
run: node scripts/ganerateCommitsHistory/index.js | |
- name: linguist-generated | |
run: node scripts/postCommit/linguist-generated.js | |
- name: Show git status & push | |
id: output | |
run: node scripts/postCommit/push.js | |
outputs: | |
commits: ${{ steps.output.outputs.commits }} | |
linterTest: ${{ steps.output.outputs.linterTest }} | |
linter_test: | |
runs-on: ubuntu-latest | |
needs: | |
- skipCI | |
- postCommit | |
if: success() && needs.skipCI.outputs.skip != 'true' && (needs.postCommit.outputs.linterTest == 'true' || github.event.inputs.manuallyLinterTest == 'true') | |
env: | |
commits: ${{ needs.postCommit.outputs.commits }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash | |
id: version | |
shell: bash | |
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v3 | |
name: Try to restore node_modules from cache | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Install dependencies if no cache for node_modules | |
run: npm run ci | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
- uses: actions/cache/save@v3 | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
name: Save node_modules to cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Reload the linter cache | |
uses: actions/cache@v3 | |
with: | |
path: .cache | |
key: cache@${{ github.ref }} | |
- name: Check eslint environment | |
run: npx eslint --env-info && mkdir -p .cache && echo ---- && ls -lhA .cache | |
- name: Run eslint | |
run: npx eslint --exit-on-fatal-error --max-warnings 0 --cache --cache-strategy content --cache-location ".cache/" --ext js ./src | |
- name: Run stylelint | |
run: npx stylelint --max-warnings 0 --cache --cache-strategy content --cache-location ".cache/" "src/**/*.css" | |
- name: Run v8r | |
run: echo "::group::v8r output" && npx v8r && echo "::endgroup::" | |
- name: Check .mailmap | |
run: node scripts/emailmapChecker/index.js | |
webhook: | |
runs-on: ubuntu-latest | |
needs: | |
- skipCI | |
- postCommit | |
- linter_test | |
if: always() && needs.skipCI.outputs.skip != 'true' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
- name: Generate cache primary key based on nodejs's and npm's version and package-lock.json's hash | |
id: version | |
shell: bash | |
run: echo "hash=node@$(node -v | grep -oP '(?<=^v)\d+')_npm@$(npm -v | grep -oP '^\d+')_package-lock@$(openssl dgst -sha3-512 package-lock.json | grep -oP '[\da-f]{128}')" >> $GITHUB_OUTPUT && cat $GITHUB_OUTPUT | |
- uses: actions/cache/restore@v3 | |
name: Try to restore node_modules from cache | |
id: cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Install dependencies if no cache for node_modules | |
run: npm run ci | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
- uses: actions/cache/save@v3 | |
if: success() && steps.cache.outputs.cache-hit != 'true' | |
name: Save node_modules to cache | |
with: | |
path: node_modules | |
key: ${{ steps.version.outputs.hash }} | |
- name: Fire the webhook of AnnAngela's server | |
run: node scripts/fireWebhook/index.js | |
env: | |
needs: ${{ toJson(needs) }} | |
ANN_SERVER_SECRET_API_KEY: ${{ secrets.ANN_SERVER_SECRET_API_KEY }} |