Skip to content

Commit

Permalink
ci: update global workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
asyncapi-bot authored Jan 10, 2022
1 parent 73da3e1 commit 1018742
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/add-good-first-issue-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#This workflow is centrally managed in https://github.com/asyncapi/.github/
#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo

#Purpose of this workflow is to enable anyone to label issue with 'Good First Issue' and 'area/*' with a single command.
name: Add 'Good First Issue' and 'area/*' labels # if proper comment added

on:
issue_comment:
types:
- created

jobs:
add-labels:
if: github.event.issue && github.event.issue.state != 'closed'
runs-on: ubuntu-latest
steps:
- name: Add label
if: contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' )
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const areas = ['javascript', 'typescript', 'java' , 'go', 'docs', 'ci-cd', 'design'];
const values = context.payload.comment.body.split(" ");
switch(values[1]){
case 'ts':
values[1] = 'typescript';
break;
case 'js':
values[1] = 'javascript';
case 'markdown':
values[1] = 'docs';
}
if(values.length != 2 || !areas.includes(values[1])){
const message = `Hey @${context.payload.sender.login}, something is wrong with your command please use \`/help\` for help.`
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
})
} else {
//remove complexity and areas if there are any before adding new labels;
const currentLabels = (await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})).data.map(label => label.name);
const shouldBeRemoved = currentLabels.filter(label => (label.startsWith('area/') && !label.endsWith(values[1])));
shouldBeRemoved.forEach(label => {
github.rest.issues.deleteLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label,
});
});
//add new labels
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['good first issue', `area/${values[1]}`]
});
}
23 changes: 19 additions & 4 deletions .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ on:
- created

jobs:
create_help_comment:
if: github.event.issue.pull_request
create_help_comment_pr:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/help')
runs-on: ubuntu-latest
steps:
- uses: actions-ecosystem/action-create-comment@v1
if: contains(github.event.comment.body, '/help')
with:
github_token: ${{ secrets.GH_TOKEN }}
body: |
Expand All @@ -25,4 +24,20 @@ jobs:
At the moment the following comments are supported in pull requests:
- `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
create_help_comment_issue:
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/help') }}
runs-on: ubuntu-latest
steps:
- uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GH_TOKEN }}
body: |
Hello, @${{ github.actor }}! 👋🏼
I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘
At the moment the following comments are supported in issues:
- `/good-first-issue {js | ts | java | go | docs | design | ci-cd} ` or `/gfi {js | ts | java | go | docs | design | ci-cd} ` - label an issue as a `good first issue`.
example: `/gfi js` or `/good-first-issue ci-cd`

0 comments on commit 1018742

Please sign in to comment.