From 7916d53e960a8fb3bf1371b10557dbfc96268ce3 Mon Sep 17 00:00:00 2001 From: Adrian Smijulj Date: Thu, 11 Jun 2020 07:50:40 +0200 Subject: [PATCH] chore: initial commit --- .gitignore | 25 +++++++++++++++++++++++++ .prettierrc.js | 12 ++++++++++++ CONTRIBUTING.md | 6 ++++++ README.md | 23 +++++++++++++++++++++-- action.yml | 5 +++++ main.ts | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 21 +++++++++++++++++++++ tsconfig.json | 6 ++++++ 8 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .prettierrc.js create mode 100644 CONTRIBUTING.md create mode 100644 action.yml create mode 100644 main.ts create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1509f98 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +.idea +.webpack +.webiny +.serverless +.env* +.npmrc +htpasswd +lerna-debug.log +npm-debug.log +node_modules +.DS_Store +coverage +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lib/ +build/ +.files/ +.changelog +.verdaccio +.history +*.tsbuildinfo +.cloudfnsrc.js +.cloudfns/ +yarn.lock diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..b5297a4 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,12 @@ +module.exports = { + printWidth: 100, + tabWidth: 2, + overrides: [ + { + files: ["*.js", "*.ts", "*.tsx"], + options: { + tabWidth: 4 + } + } + ] +}; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..35b1488 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +Commit all of the changes you have locally, then use the following commands to create a tag and push everything: + +``` +git tag -a -m "Release v1.0.19" v1.0.19 +git push --follow-tags +``` diff --git a/README.md b/README.md index 8c7a5ba..75e74e8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ -# action-conventional-commits -Ensures that all commits are following the conventional-commits standard. +# Hello world javascript action + +This action prints "Hello World" or "Hello" + the name of a person to greet to the log. + +## Inputs + +### `who-to-greet` + +**Required** The name of the person to greet. Default `"World"`. + +## Outputs + +### `time` + +The time we greeted you. + +## Example usage + +uses: actions/hello-world-javascript-action@v1 +with: + who-to-greet: 'Mona the Octocat' diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..7e4b3d7 --- /dev/null +++ b/action.yml @@ -0,0 +1,5 @@ +name: "Conventional Commits" +description: "Ensures that all commit messages are following the conventional-commits standard." +runs: + using: node12 + main: dist/main/index.js diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..c5438fa --- /dev/null +++ b/main.ts @@ -0,0 +1,38 @@ +import { Contreebutors } from "contreebutors"; +const { GitHub, context } = require('@actions/github'); + +(async () => { + const core = require("@actions/core"); + const exec = require("@actions/exec"); + + // 1. Extract a list of users from received commits. + const token = process.env.GH_TOKEN; + + const client = new GitHub(token, {}); + const result = await client.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: context.sha, + }); + + const pr = result.data.length > 0 && result.data[0]; + + core.setOutput('pr', pr && pr.number || ''); + 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. + +})(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea4ffb3 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "action-conventional-commits", + "version": "1.0.0", + "main": "index.js", + "repository": "git@github.com:doitadrian/action-conventional-commits.git", + "author": "Adrian Smijulj ", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.2.3", + "@actions/exec": "^1.0.3", + "@actions/github": "^2.1.1" + }, + "devDependencies": { + "@zeit/ncc": "^0.22.0", + "prettier": "^2.0.2" + }, + "scripts": { + "build": "ncc build main.ts --out dist/main", + "watch": "ncc build main.ts --out dist/main --watch" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..57dce1f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "es2015", + "moduleResolution": "node" + } +}