mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat: add add loabl
This commit is contained in:
11
.github/github-action/action.yml
vendored
11
.github/github-action/action.yml
vendored
@@ -1,13 +1,10 @@
|
|||||||
name: 'Hello World'
|
name: 'Hello World'
|
||||||
description: 'Greet someone and record the time'
|
description: 'Greet someone and record the time'
|
||||||
inputs:
|
inputs:
|
||||||
who-to-greet: # id of input
|
github_token:
|
||||||
description: 'Who to greet'
|
description: A GitHub token.
|
||||||
required: true
|
required: false
|
||||||
default: 'World'
|
default: ${{ github.token }}
|
||||||
outputs:
|
|
||||||
time: # id of output
|
|
||||||
description: 'The time we greeted you'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'index.js'
|
main: 'index.js'
|
||||||
|
|||||||
16
.github/github-action/contributors.js
vendored
Normal file
16
.github/github-action/contributors.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const contributors = [
|
||||||
|
'tomalaforge',
|
||||||
|
'alcaidio',
|
||||||
|
'svenson95',
|
||||||
|
'jdegand',
|
||||||
|
'DeveshChau',
|
||||||
|
'stillst',
|
||||||
|
'wandri',
|
||||||
|
'webbomj',
|
||||||
|
'kabrunko-dev',
|
||||||
|
'Sanjar1304'
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
contributors
|
||||||
|
};
|
||||||
57
.github/github-action/index.js
vendored
57
.github/github-action/index.js
vendored
@@ -1,15 +1,48 @@
|
|||||||
const core = require('@actions/core');
|
|
||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
const contributors = require('./contributors');
|
||||||
|
|
||||||
try {
|
async function run() {
|
||||||
// `who-to-greet` input defined in action metadata file
|
try {
|
||||||
const nameToGreet = core.getInput('who-to-greet');
|
const title = github.context.payload.pull_request.title;
|
||||||
console.log(`Hello ${nameToGreet}!`);
|
const labels = [];
|
||||||
const time = (new Date()).toTimeString();
|
|
||||||
core.setOutput("time", time);
|
if(!title.startsWith('Answer:')) {
|
||||||
// Get the JSON webhook payload for the event that triggered the workflow
|
return;
|
||||||
const payload = JSON.stringify(github.context.payload, undefined, 2)
|
}
|
||||||
console.log(`The event payload: ${payload}`);
|
labels.push('answer');
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error.message);
|
const match = title.match(/Answer:\s*(\d+)/);
|
||||||
|
if (match) {
|
||||||
|
labels.push(parseInt(match[1], 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
const actor = github.context.actor;
|
||||||
|
if(contributors.includes(actor)) {
|
||||||
|
labels.push('to be reviewed');
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubToken = core.getInput('github_token');
|
||||||
|
|
||||||
|
const [owner, repo] = core.getInput('repo').split('/');
|
||||||
|
const number =
|
||||||
|
core.getInput('number') === ''
|
||||||
|
? github.context.issue.number
|
||||||
|
: parseInt(core.getInput('number'));
|
||||||
|
|
||||||
|
const octokit = github.getOctokit(githubToken);
|
||||||
|
await octokit.rest.issues.addLabels({
|
||||||
|
labels,
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
issue_number: number
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
core.error(e);
|
||||||
|
core.setFailed(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
|
|||||||
21
.github/workflows/label-issue.yml
vendored
21
.github/workflows/label-issue.yml
vendored
@@ -14,24 +14,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm i @actions/core @actions/github
|
run: npm i @actions/core @actions/github
|
||||||
|
|
||||||
- name: add supporter labels
|
- name: Add labels
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
|
||||||
if: ${{ contains( fromJson('[ "tomalaforge", "alcaidio" , "svenson95", "jdegand", "DeveshChau", "stillst", "wandri", "webbomj", "kabrunko-dev", "Sanjar1304"]'), github.actor ) && startsWith(github.event.pull_request.title, 'Answer') }}
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.github_token }}
|
|
||||||
labels: supporter
|
|
||||||
|
|
||||||
- name: add answer labels
|
|
||||||
uses: actions-ecosystem/action-add-labels@v1
|
|
||||||
if: ${{ startsWith(github.event.pull_request.title, 'Answer') }}
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.github_token }}
|
|
||||||
labels: answer
|
|
||||||
|
|
||||||
- name: Hello world action step
|
|
||||||
uses: ./.github/github-action/
|
uses: ./.github/github-action/
|
||||||
id: hello
|
|
||||||
with:
|
with:
|
||||||
who-to-greet: 'Mona the Octocat'
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Get the output time
|
|
||||||
run: echo "The time was ${{ steps.hello.outputs.time }}"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user