mirror of
https://github.com/webiny/action-conventional-commits.git
synced 2024-11-10 12:09:34 +01:00
feat: create action-conventional-commits
This commit is contained in:
parent
672b80eed8
commit
7bb041923b
2 changed files with 43 additions and 1225 deletions
1207
dist/main/index.js
vendored
1207
dist/main/index.js
vendored
File diff suppressed because it is too large
Load diff
55
main.ts
55
main.ts
|
@ -1,40 +1,29 @@
|
||||||
const { GitHub, context } = require("@actions/github");
|
const { context } = require("@actions/github");
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const exec = require("@actions/exec");
|
|
||||||
|
|
||||||
console.log('woaaah')
|
const isValidCommitMessage = message => message.match(/^[a-z].*:/);
|
||||||
console.log("context", JSON.stringify(context.payload.commits));
|
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
core.info(
|
||||||
|
`ℹ️ Checking if commit messages are following the Conventional Commits specification...`
|
||||||
|
);
|
||||||
|
|
||||||
|
const hasCommits = context.payload && Array.isArray(context.payload.commits);
|
||||||
|
if (!hasCommits) {
|
||||||
|
core.info(`No commits to check, skipping...`);
|
||||||
return;
|
return;
|
||||||
// 1. Extract a list of users from received commits.
|
}
|
||||||
/* const token = process.env.GH_TOKEN;
|
|
||||||
|
|
||||||
const client = new GitHub(token, {});
|
for (let i = 0; i < context.payload.commits.length; i++) {
|
||||||
const result = await client.({
|
let commit = context.payload.commits[i];
|
||||||
owner: context.repo.owner,
|
if (!isValidCommitMessage(commit.message)) {
|
||||||
repo: context.repo.repo,
|
core.setFailed(
|
||||||
commit_sha: context.sha,
|
`According to the conventional-commits specification, commit message ${commit.message} is not valid.`
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const pr = result.data.length > 0 && result.data[0];
|
core.info("🎉 All commit messages are following the Conventional Commits specification.");
|
||||||
|
}
|
||||||
|
|
||||||
core.setOutput('pr', pr && pr.number || '');
|
run();
|
||||||
core.setOutput('number', pr && pr.number || '');
|
|
||||||
core.setOutput('title', pr && pr.title || '');
|
|
||||||
core.setOutput('body', pr && pr.body || '');
|
|
||||||
|
|
||||||
|
|
||||||
// 2. Add them to the list.
|
|
||||||
const contreebutors = new Contreebutors();
|
|
||||||
|
|
||||||
for (let i = 0; i < users.length; i++) {
|
|
||||||
let user = users[i];
|
|
||||||
await contreebutors.add(user);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// 3. Commit changes done on the `contreebutors.json` and `README.md` file.
|
|
||||||
|
|
||||||
// 4. Add comment to the merged PR - notify the user that he was added to the contributors list.
|
|
||||||
})();
|
|
||||||
|
|
Loading…
Reference in a new issue