Skip to content

Commit

Permalink
ci: update global workflows (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
asyncapi-bot authored Mar 29, 2022
1 parent d6dd98d commit 89e8f2a
Show file tree
Hide file tree
Showing 22 changed files with 147 additions and 69 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/add-good-first-issue-labels.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#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
# 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.
# 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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,64 @@
#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
# 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 PR with `ready-to-merge` and `do-not-merge` labels to get stuff merged or blocked from merging
name: Add ready-to-merge or do-not-merge label # if proper comment added
# Purpose of this workflow is to enable anyone to label PR with the following labels:
# `ready-to-merge` and `do-not-merge` labels to get stuff merged or blocked from merging
# `autoupdate` to keep a branch up-to-date with the target branch

name: Label PRs # if proper comment added

on:
issue_comment:
types:
- created

jobs:
parse-comment-and-add-ready: # for handling cases when you want to mark as ready to merge
if: github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot'
add-ready-to-merge-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/ready-to-merge') ||
contains(github.event.comment.body, '/rtm' )
)
runs-on: ubuntu-latest
steps:
- name: Check if PR is draft # such info is not available in the context of issue_comment event

- name: Check if PR is draft or is up-to-date # such info is not available in the context of issue_comment event
uses: actions/github-script@v5
id: checkDraft
id: checkPR
with:
result-encoding: string
script: |
let isDraft = false;
let isUpToDate = true;
const prDetailsUrl = context.payload.issue.pull_request.url;
const response = await github.request(prDetailsUrl);
return response.data.draft;
- name: Add label
if: steps.checkDraft.outputs.result == 'false' && (contains(github.event.comment.body, '/ready-to-merge') || contains(github.event.comment.body, '/rtm' ))
const { data: pull } = await github.request(prDetailsUrl);
isDraft = pull.draft;
const { data: comparison } =
await github.rest.repos.compareCommitsWithBasehead({
owner: pull.head.repo.owner.login,
repo: pull.head.repo.name,
basehead: `${pull.head.label}...${pull.base.label}`,
});
if (comparison.behind_by !== 0) isUpToDate = false;
return { isDraft, isUpToDate };
- uses: actions-ecosystem/action-create-comment@v1
if: ${{ !steps.checkPR.outputs.result.isUpToDate }}
with:
github_token: ${{ secrets.GH_TOKEN }}
body: |
Hello, @${{ github.actor }}! 👋🏼
This PR is not up to date with the base branch and can't be merged.
You can add comment to this PR with text: `/autoupdate` or `/au`. This way you ask our bot to perform regular updates for you. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Otherwise the only option that you have is to manually update your branch with latest version of the base branch.
Thanks 😄
- name: Add ready-to-merge label
if: ${{ !steps.checkPR.outputs.result.isDraft }}
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_TOKEN }}
Expand All @@ -36,12 +70,18 @@ jobs:
labels: ['ready-to-merge']
})
parse-comment-and-add-block: # for handling cases when you want to mark as do-not-merge
if: github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot'
add-do-not-merge-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/do-not-merge') ||
contains(github.event.comment.body, '/dnm' )
)
runs-on: ubuntu-latest
steps:
- name: Add label
if: contains(github.event.comment.body, '/do-not-merge') || contains(github.event.comment.body, '/dnm' )
- name: Add do-not-merge label
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_TOKEN }}
Expand All @@ -51,4 +91,26 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['do-not-merge']
})
add-autoupdate-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/autoupdate') ||
contains(github.event.comment.body, '/au' )
)
runs-on: ubuntu-latest
steps:
- name: Add autoupdate label
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['autoupdate']
})
6 changes: 3 additions & 3 deletions .github/workflows/automerge-for-humans-merging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#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
# 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 allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT!
# Purpose of this workflow is to allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT!
name: Automerge For Humans

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#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
# 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

# Defence from evil contributor that after adding `ready-to-merge` all suddenly makes evil commit or evil change in PR title
# Label is removed once above action is detected
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automerge-orphans.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This action 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
# This action 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

name: 'Notify on failing automerge'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['autoapproved']
labels: ['autoapproved', 'autoupdate']
})
automerge-for-bot:
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#This action 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
# This action 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

#This workflow is designed to work with:
# This workflow is designed to work with:
# - autoapprove and automerge workflows for dependabot and asyncapibot.
# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against

# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
#Autoupdating to latest destination branch works only in the context of upstream repo and not forks
# Autoupdating to latest destination branch works only in the context of upstream repo and not forks

name: autoupdate

Expand All @@ -17,9 +17,13 @@ on:
- 'dependabot/**'
- 'bot/**'
- 'all-contributors/**'
pull_request:
types:
- labeled

jobs:
autoupdate-for-bot:
if: ${{ !github.event.issue.pull_request || contains(github.event.pull_request.labels.*.name, 'autoupdate') }}
name: Autoupdate autoapproved PR created in the upstream
runs-on: ubuntu-latest
steps:
Expand All @@ -28,6 +32,6 @@ jobs:
env:
GITHUB_TOKEN: '${{ secrets.GH_TOKEN }}'
PR_FILTER: "labelled"
PR_LABELS: "autoapproved"
PR_LABELS: "autoupdate"
PR_READY_STATE: "ready_for_review"
MERGE_CONFLICT_ACTION: "ignore"
14 changes: 7 additions & 7 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#This action 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
# This action 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 action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only.
#It runs in a repo after merge of release commit and searches for other packages that use released package. Every found package gets updated with lates version
# Purpose of this action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only.
# It runs in a repo after merge of release commit and searches for other packages that use released package. Every found package gets updated with lates version

name: Bump package version in dependent repos - if Node project

on:
#It cannot run on release event as when release is created then version is not yet bumped in package.json
#This means we cannot extract easily latest version and have a risk that package is not yet on npm
# It cannot run on release event as when release is created then version is not yet bumped in package.json
# This means we cannot extract easily latest version and have a risk that package is not yet on npm
push:
branches:
- master
Expand All @@ -31,4 +31,4 @@ jobs:
github_token: ${{ secrets.GH_TOKEN }}
committer_username: asyncapi-bot
committer_email: [email protected]
repos_to_ignore: html-template #this is temporary until react component releases 1.0, then it can be removed
repos_to_ignore: html-template # this is temporary until react component releases 1.0, then it can be removed
5 changes: 3 additions & 2 deletions .github/workflows/help-command.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#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
# 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

name: Create help comment

Expand All @@ -25,6 +25,7 @@ jobs:
- `/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
- `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch. Unless there is a merge conflict.
create_help_comment_issue:
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
runs-on: ubuntu-latest
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/if-go-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#This action 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
#It does magic only if there is go.mod file in the root of the project
# This action 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

# It does magic only if there is go.mod file in the root of the project
name: PR testing - if Go project

on:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#This action 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
#It does magic only if there is package.json file in the root of the project
# This action 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

# It does magic only if there is package.json file in the root of the project
name: PR testing - if Node project

on:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#This action 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
#It does magic only if there is package.json file in the root of the project
# This action 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

# It does magic only if there is package.json file in the root of the project
name: Release - if Node project

on:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/if-nodejs-version-bump.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#This action 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
#It does magic only if there is package.json file in the root of the project
# This action 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

# It does magic only if there is package.json file in the root of the project
name: Version bump - if Node.js project

on:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issues-prs-notifications.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#This action 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
# This action 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

#This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
# This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
name: Notify slack

on:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/link-check-cron.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 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

name: Check Markdown links (Weekly)

on:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/link-check-pr.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 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

name: Check Markdown links

on:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This action 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
# This action 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

name: Lint PR title

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/notify-tsc-members-mention.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#This action 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
# This action 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

#This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
# This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
name: Notify slack whenever TSC members are mentioned in GitHub

on:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-announcements.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#This action 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
# This action 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

name: 'Announce releases in different channels'

on:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sentiment-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This action 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
# This action 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

name: 'Sentiment Analysis'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale-issues-prs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#This action 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
# This action 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

name: Manage stale issues and PRs

Expand Down
Loading

0 comments on commit 89e8f2a

Please sign in to comment.