Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update global workflows #27

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:/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`