-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from TimonVS/chore/10
Refactor to use @actions/core instead of deprecated actions-toolkit
- Loading branch information
Showing
10 changed files
with
233 additions
and
285 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ branding: | |
icon: 'tag' | ||
color: 'white' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
using: 'node12' | ||
main: 'index.js' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,27 @@ | ||
const { Toolkit } = require('actions-toolkit') | ||
const getConfig = require('./utils/config') | ||
const matcher = require('matcher') | ||
const distPath = './dist/index.js' | ||
const errorMessage = `ERROR: since pr-labeler-action v3, binding to the master version is no longer supported. Please update .github/workflows/pr-labeler.yml to bind to a major version. | ||
const CONFIG_FILENAME = 'pr-labeler.yml' | ||
const defaults = { | ||
feature: ['feature/*', 'feat/*'], | ||
fix: 'fix/*', | ||
chore: 'chore/*' | ||
} | ||
|
||
Toolkit.run( | ||
async tools => { | ||
const repoInfo = { | ||
owner: tools.context.payload.repository.owner.login, | ||
repo: tools.context.payload.repository.name | ||
} | ||
const ref = tools.context.payload.pull_request.head.ref | ||
const config = { | ||
...defaults, | ||
...(await getConfig(tools.github, CONFIG_FILENAME, repoInfo, ref)) | ||
} | ||
You can do so by changing: | ||
- uses: TimonVS/pr-labeler-action@master | ||
const labelsToAdd = Object.entries(config).reduce( | ||
(labels, [label, patterns]) => { | ||
if ( | ||
Array.isArray(patterns) | ||
? patterns.some(pattern => matcher.isMatch(ref, pattern)) | ||
: matcher.isMatch(ref, patterns) | ||
) { | ||
labels.push(label) | ||
} | ||
To: | ||
- uses: TimonVS/pr-labeler-action@v3 | ||
return labels | ||
}, | ||
[] | ||
) | ||
Please check the repository (https://github.com/TimonVS/pr-labeler-action) for the latest version. | ||
` | ||
|
||
if (labelsToAdd.length > 0) { | ||
await tools.github.issues.addLabels({ | ||
number: tools.context.payload.pull_request.number, | ||
labels: labelsToAdd, | ||
...repoInfo | ||
}) | ||
} | ||
try { | ||
require(distPath) | ||
} catch (error) { | ||
if (error.code !== 'MODULE_NOT_FOUND') { | ||
// Re-throw not "Module not found" errors | ||
throw error | ||
} | ||
if (error.message.indexOf(distPath) === -1) { | ||
// Re-throw not found errors for other modules | ||
throw error | ||
} | ||
|
||
tools.exit.success() | ||
}, | ||
{ event: 'pull_request.opened', secrets: ['GITHUB_TOKEN'] } | ||
) | ||
console.error(errorMessage) | ||
throw error | ||
} |
Oops, something went wrong.