5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 16:06:56 +00:00

Merge pull request #42 from wagoid/feat/upgrade-commitlint-deps

feat: upgrade commitlint deps
This commit is contained in:
Wagner Santos 2020-08-02 11:25:16 -03:00 committed by GitHub
commit 98391a559b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 667 additions and 280 deletions

View file

@ -4,8 +4,6 @@ on: [push, pull_request]
jobs: jobs:
commitlint: commitlint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -19,8 +17,6 @@ jobs:
run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }} run: echo ${{ toJSON(steps.run_commitlint.outputs.results) }}
commitlint-with-yml-file: commitlint-with-yml-file:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -32,8 +28,6 @@ jobs:
configFile: './.commitlintrc.yml' configFile: './.commitlintrc.yml'
commitlint-pulling-from-docker-hub: commitlint-pulling-from-docker-hub:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:

View file

@ -7,19 +7,17 @@ Lints Pull Request commits with commitlint
Create a github workflow in the `.github` folder, e.g. `.github/workflows/commitlint.yml`: Create a github workflow in the `.github` folder, e.g. `.github/workflows/commitlint.yml`:
```yaml ```yaml
name: Commitlint name: Lint Commit Messages
on: [pull_request] on: [pull_request]
jobs: jobs:
lint: commitlint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: wagoid/commitlint-github-action@v1 - uses: wagoid/commitlint-github-action@v2
``` ```
Alternatively, you can run on other event types such as `on: [push]`. In that case the action will lint the push event's commit(s) instead of linting commits from a pull request. You can also combine `push` and `pull_request` together in the same workflow. Alternatively, you can run on other event types such as `on: [push]`. In that case the action will lint the push event's commit(s) instead of linting commits from a pull request. You can also combine `push` and `pull_request` together in the same workflow.
@ -54,6 +52,14 @@ Link to a page explaining your commit message convention.
default: `https://github.com/conventional-changelog/commitlint/#what-is-commitlint` default: `https://github.com/conventional-changelog/commitlint/#what-is-commitlint`
### `token`
Personal access token (PAT) used to interact with the GitHub API.
By default, the automatic token provided by GitHub is used.
You can see more info about GitHub's default token [here](https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token).
default: `${{ github.token }}`
## Outputs ## Outputs
### `results` ### `results`
@ -114,14 +120,12 @@ Apart from the shared configurations that are included by default, you can also
In order to do so, you can use `NODE_PATH` env var to make the action take those dependencies into account. Below is an example workflow that does that. In order to do so, you can use `NODE_PATH` env var to make the action take those dependencies into account. Below is an example workflow that does that.
```yaml ```yaml
name: Commitlint name: Lint Commit Messages
on: [pull_request] on: [pull_request]
jobs: jobs:
lint: commitlint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -134,7 +138,7 @@ jobs:
# $GITHUB_WORKSPACE is the path to your repository # $GITHUB_WORKSPACE is the path to your repository
run: echo "::set-env name=NODE_PATH::$GITHUB_WORKSPACE/node_modules" run: echo "::set-env name=NODE_PATH::$GITHUB_WORKSPACE/node_modules"
# Now the commitlint action will run considering its own dependencies and yours as well 🚀 # Now the commitlint action will run considering its own dependencies and yours as well 🚀
- uses: wagoid/commitlint-github-action@v1 - uses: wagoid/commitlint-github-action@v2
``` ```
--- ---

View file

@ -7,7 +7,9 @@ inputs:
default: './commitlint.config.js' default: './commitlint.config.js'
required: false required: false
firstParent: firstParent:
description: 'When set to true, we follow only the first parent commit when seeing a merge commit. More info in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent' description: >
When set to true, we follow only the first parent commit when seeing a merge commit.
More info in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent
default: 'true' default: 'true'
required: false required: false
failOnWarnings: failOnWarnings:
@ -18,6 +20,13 @@ inputs:
description: 'Link to a page explaining your commit message convention' description: 'Link to a page explaining your commit message convention'
default: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' default: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
required: false required: false
token:
description: >
Personal access token (PAT) used to interact with the GitHub API.
By default, the automatic token provided by GitHub is used.
You can see more info about GitHub's default token here: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
default: ${{ github.token }}
required: false
outputs: outputs:
results: results:
description: The error and warning messages for each one of the analyzed commits description: The error and warning messages for each one of the analyzed commits

View file

@ -1,9 +1,5 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
module.exports = { module.exports = {
// Automatically clear mock calls and instances between every test // Automatically clear mock calls and instances between every test
clearMocks: true, clearMocks: true,
// The test environment that will be used for testing testEnvironment: '@commitlint/test-environment',
testEnvironment: 'node',
} }

871
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -17,22 +17,23 @@
"dependencies": { "dependencies": {
"@actions/core": "^1.2.4", "@actions/core": "^1.2.4",
"@actions/github": "^1.1.0", "@actions/github": "^1.1.0",
"@commitlint/config-angular": "^8.3.4", "@commitlint/config-angular": "^9.1.1",
"@commitlint/config-conventional": "^8.3.4", "@commitlint/config-conventional": "^9.1.1",
"@commitlint/config-lerna-scopes": "^8.3.4", "@commitlint/config-lerna-scopes": "^9.1.1",
"@commitlint/config-patternplate": "^8.3.4", "@commitlint/config-patternplate": "^9.1.1",
"@commitlint/format": "^8.3.4", "@commitlint/format": "^9.1.1",
"@commitlint/lint": "^8.3.5", "@commitlint/lint": "^9.1.1",
"@commitlint/load": "^8.3.5", "@commitlint/load": "^9.1.1",
"commitlint-config-jira": "^1.2.0", "commitlint-config-jira": "^1.4.1",
"commitlint-plugin-jira-rules": "^1.2.0", "commitlint-plugin-jira-rules": "^1.4.0",
"conventional-changelog-lint-config-canonical": "^1.0.0", "conventional-changelog-lint-config-canonical": "^1.0.0",
"dargs": "^7.0.0", "dargs": "^7.0.0",
"execa": "^4.0.3", "execa": "^4.0.3",
"lerna": "^3.18.1" "lerna": "^3.18.1"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/test": "^8.2.0", "@commitlint/test": "^9.0.1",
"@commitlint/test-environment": "^9.0.1",
"conventional-changelog-cli": "^2.0.23", "conventional-changelog-cli": "^2.0.23",
"husky": "^3.0.7", "husky": "^3.0.7",
"jest": "^24.9.0", "jest": "^24.9.0",

View file

@ -2,15 +2,15 @@ const { existsSync } = require('fs')
const { resolve } = require('path') const { resolve } = require('path')
const core = require('@actions/core') const core = require('@actions/core')
const github = require('@actions/github') const github = require('@actions/github')
const lint = require('@commitlint/lint') const lint = require('@commitlint/lint').default
const { format } = require('@commitlint/format') const { format } = require('@commitlint/format')
const load = require('@commitlint/load') const load = require('@commitlint/load').default
const gitCommits = require('./gitCommits') const gitCommits = require('./gitCommits')
const generateOutputs = require('./generateOutputs') const generateOutputs = require('./generateOutputs')
const pullRequestEvent = 'pull_request' const pullRequestEvent = 'pull_request'
const { GITHUB_TOKEN, GITHUB_EVENT_NAME, GITHUB_SHA } = process.env const { GITHUB_EVENT_NAME, GITHUB_SHA } = process.env
const configPath = resolve( const configPath = resolve(
process.env.GITHUB_WORKSPACE, process.env.GITHUB_WORKSPACE,
@ -47,7 +47,7 @@ const getRangeForPushEvent = () => {
const getRangeForEvent = async () => { const getRangeForEvent = async () => {
if (GITHUB_EVENT_NAME !== pullRequestEvent) return getRangeForPushEvent() if (GITHUB_EVENT_NAME !== pullRequestEvent) return getRangeForPushEvent()
const octokit = new github.GitHub(GITHUB_TOKEN) const octokit = new github.GitHub(core.getInput('token'))
const { owner, repo, number } = eventContext.issue const { owner, repo, number } = eventContext.issue
const { data: commits } = await octokit.pulls.listCommits({ const { data: commits } = await octokit.pulls.listCommits({
owner, owner,