-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c8b765
commit 4c3666e
Showing
14 changed files
with
536 additions
and
36 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#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 | ||
|
||
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' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if PR is draft # such info is not available in the context of issue_comment event | ||
uses: actions/github-script@v5 | ||
id: checkDraft | ||
with: | ||
result-encoding: string | ||
script: | | ||
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' )) | ||
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: ['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' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add label | ||
if: contains(github.event.comment.body, '/do-not-merge') || contains(github.event.comment.body, '/dnm' ) | ||
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: ['do-not-merge'] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#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! | ||
name: Automerge For Humans | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- labeled | ||
- unlabeled | ||
- synchronize | ||
- opened | ||
- edited | ||
- ready_for_review | ||
- reopened | ||
- unlocked | ||
|
||
jobs: | ||
automerge-for-humans: | ||
if: github.event.pull_request.draft == false && (github.event.pull_request.user.login != 'asyncapi-bot' || github.event.pull_request.user.login != 'dependabot[bot]' || github.event.pull_request.user.login != 'dependabot-preview[bot]') #it runs only if PR actor is not a bot, at least not a bot that we know | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Automerge PR | ||
uses: pascalgn/[email protected] | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" | ||
MERGE_LABELS: "!do-not-merge,ready-to-merge" | ||
MERGE_METHOD: "squash" | ||
MERGE_COMMIT_MESSAGE: "pull-request-title" | ||
MERGE_RETRIES: "20" | ||
MERGE_RETRY_SLEEP: "30000" |
35 changes: 35 additions & 0 deletions
35
.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#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 | ||
name: Remove ready-to-merge label | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- synchronize | ||
- edited | ||
|
||
jobs: | ||
remove-ready-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Remove label | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.GH_TOKEN }} | ||
script: | | ||
const labelToRemove = 'ready-to-merge'; | ||
const labels = context.payload.pull_request.labels; | ||
const isLabelPresent = labels.some(label => label.name === labelToRemove) | ||
if(!isLabelPresent) return; | ||
github.rest.issues.removeLabel({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: labelToRemove | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Automerge release bump PR | ||
|
||
|
@@ -17,31 +17,43 @@ on: | |
pull_request_review: | ||
types: | ||
- submitted | ||
|
||
jobs: | ||
|
||
autoapprove: | ||
if: github.event.pull_request.draft == false | ||
if: github.event.pull_request.draft == false && (github.event.pull_request.user.login == 'asyncapi-bot' || github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot-preview[bot]') && !contains(github.event.pull_request.labels.*.name, 'released') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Autoapproving | ||
uses: hmarr/auto-approve-action@v2 | ||
if: github.actor == ('asyncapi-bot' || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') && !contains(github.event.pull_request.labels.*.name, 'released') | ||
with: | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Label autoapproved | ||
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: ['autoapproved'] | ||
}) | ||
automerge: | ||
needs: [autoapprove] | ||
if: github.event.pull_request.user.login == 'asyncapi-bot' || github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot-preview[bot]' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Automerging | ||
uses: pascalgn/[email protected] | ||
if: github.actor == 'asyncapi-bot' || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" | ||
GITHUB_LOGIN: asyncapi-bot | ||
MERGE_LABELS: "" | ||
MERGE_METHOD: "squash" | ||
MERGE_COMMIT_MESSAGE: "pull-request-title" | ||
MERGE_RETRIES: "20" | ||
MERGE_RETRY_SLEEP: "30000" | ||
MERGE_RETRY_SLEEP: "30000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#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: | ||
# - 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 | ||
|
||
name: autoupdate | ||
|
||
on: | ||
push: {} | ||
|
||
jobs: | ||
|
||
autoupdate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Autoupdating | ||
uses: docker://chinthakagodawita/autoupdate-action:v1 | ||
env: | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||
PR_FILTER: "labelled" | ||
PR_LABELS: "autoapproved" | ||
PR_READY_STATE: "ready_for_review" | ||
MERGE_CONFLICT_ACTION: "ignore" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#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 | ||
|
||
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 | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
bump: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Check if Node.js project and has package.json | ||
id: packagejson | ||
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" | ||
- if: steps.packagejson.outputs.exists == 'true' && startsWith(github.event.commits[0].message, 'chore(release):') | ||
name: Bumping latest version of this package in other repositories | ||
uses: derberg/npm-dependency-manager-for-your-github-org@v3 | ||
with: | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#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 | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
jobs: | ||
create_help_comment: | ||
if: github.event.issue.pull_request | ||
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: | | ||
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 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#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: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
version_bump: | ||
name: Generate assets and bump | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
# target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases | ||
# in case release is created from release branch then we need to checkout from given branch | ||
# if @semantic-release/github is used to publish, the minimum version is 7.2.0 for proper working | ||
ref: ${{ github.event.release.target_commitish }} | ||
- name: Check if Node.js project and has package.json | ||
id: packagejson | ||
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Install dependencies | ||
run: npm install | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Assets generation | ||
run: npm run generate:assets | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Bump version in package.json | ||
# There is no need to substract "v" from the tag as version script handles it | ||
# When adding "bump:version" script in package.json, make sure no tags are added by default (--no-git-tag-version) as they are already added by release workflow | ||
# When adding "bump:version" script in package.json, make sure --allow-same-version is set in case someone forgot and updated package.json manually and we want to avoide this action to fail and raise confusion | ||
run: VERSION=${{github.event.release.tag_name}} npm run bump:version | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Create Pull Request with updated asset files including package.json | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
commit-message: 'chore(release): ${{github.event.release.tag_name}}' | ||
committer: asyncapi-bot <[email protected]> | ||
author: asyncapi-bot <[email protected]> | ||
title: 'chore(release): ${{github.event.release.tag_name}}' | ||
body: 'Version bump in package.json for release [${{github.event.release.tag_name}}](${{github.event.release.html_url}})' | ||
branch: version-bump/${{github.event.release.tag_name}} |
Oops, something went wrong.