feat: new workflow feature x #3
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: Style | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
# Event list: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows | |
pull_request: | |
types: [opened, edited, synchronize] | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
install-and-lint-pr-title: | |
runs-on: ubuntu-latest | |
name: Conventional commits style check | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install conventional commits linter | |
run: npm install --save-dev @commitlint/config-conventional @commitlint/cli | |
- name: Configure commitlint | |
run: | | |
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js | |
- name: Lint current pull request title | |
run: jq --raw-output ".pull_request.title" "$GITHUB_EVENT_PATH" | npx commitlint --verbose | |
# The code below is saved for future references. | |
# env: | |
# GH_TOKEN: ${{ github.token }} | |
# pr_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | |
# gh pr view $pr_number --json=title --jq '.title' | npx commitlint --verbose |