diff --git a/.github/workflows/add-good-first-issue-labels.yml b/.github/workflows/add-good-first-issue-labels.yml new file mode 100644 index 0000000..00acdb8 --- /dev/null +++ b/.github/workflows/add-good-first-issue-labels.yml @@ -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.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, '/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}, your message doesn't follow the requirements, you can try \`/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]}`] + }); + } diff --git a/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml new file mode 100644 index 0000000..d35c321 --- /dev/null +++ b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml @@ -0,0 +1,116 @@ +# 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 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: + 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 or is up-to-date # such info is not available in the context of issue_comment event + uses: actions/github-script@v5 + id: checkPR + with: + result-encoding: string + script: | + let isDraft = false; + let isUpToDate = true; + const prDetailsUrl = context.payload.issue.pull_request.url; + 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 }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['ready-to-merge'] + }) + + 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 do-not-merge 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: ['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'] + }) \ No newline at end of file diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml new file mode 100644 index 0000000..e1b4deb --- /dev/null +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -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/automerge-action@v0.14.3 + env: + GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + MERGE_LABELS: "!do-not-merge,ready-to-merge" + MERGE_METHOD: "squash" + MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" + MERGE_RETRIES: "20" + MERGE_RETRY_SLEEP: "30000" \ No newline at end of file diff --git a/.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml b/.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml new file mode 100644 index 0000000..f38296c --- /dev/null +++ b/.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml @@ -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 + }) diff --git a/.github/workflows/automerge-orphans.yml b/.github/workflows/automerge-orphans.yml new file mode 100644 index 0000000..5c39ba9 --- /dev/null +++ b/.github/workflows/automerge-orphans.yml @@ -0,0 +1,63 @@ +# 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' + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + identify-orphans: + name: Find orphans and notify + runs-on: ubuntu-latest + steps: + - name: Get list of orphans + uses: actions/github-script@v3 + id: orphans + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const query = `query($owner:String!, $name:String!) { + repository(owner:$owner, name:$name){ + pullRequests(first: 100, states: OPEN){ + nodes{ + title + url + author { + resourcePath + } + } + } + } + }`; + const variables = { + owner: context.repo.owner, + name: context.repo.repo + }; + const { repository: { pullRequests: { nodes } } } = await github.graphql(query, variables); + + let orphans = nodes.filter( (pr) => pr.author.resourcePath === '/asyncapi-bot' || pr.author.resourcePath === '/apps/dependabot') + + if (orphans.length) { + core.setOutput('found', 'true'); + //Yes, this is very naive approach to assume there is just one PR causing issues, there can be a case that more PRs are affected the same day + //The thing is that handling multiple PRs will increase a complexity in this PR that in my opinion we should avoid + //The other PRs will be reported the next day the action runs, or person that checks first url will notice the other ones + core.setOutput('url', orphans[0].url); + core.setOutput('title', orphans[0].title); + } + - if: steps.orphans.outputs.found == 'true' + name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: issuemarkdown + with: + text: "-> [${{steps.orphans.outputs.title}}](${{steps.orphans.outputs.url}})" + - if: steps.orphans.outputs.found == 'true' + name: Send info about orphan to slack + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} + SLACK_TITLE: 🚨 Not merged PR that should be automerged 🚨 + SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} + MSG_MINIMAL: true \ No newline at end of file diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..052a19c --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,52 @@ +# 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 + +on: + pull_request_target: + types: + - opened + - synchronize + +jobs: + autoapprove-for-bot: + name: Autoapprove PR comming from a bot + if: > + contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.event.pull_request.user.login) && + contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.actor) && + !contains(github.event.pull_request.labels.*.name, 'released') + runs-on: ubuntu-latest + steps: + - name: Autoapproving + uses: hmarr/auto-approve-action@v2 + with: + github-token: "${{ secrets.GH_TOKEN_BOT_EVE }}" + + - 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', 'autoupdate'] + }) + + automerge-for-bot: + name: Automerge PR autoapproved by a bot + needs: [autoapprove-for-bot] + runs-on: ubuntu-latest + steps: + - name: Automerging + uses: pascalgn/automerge-action@v0.13.0 + env: + GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + GITHUB_LOGIN: asyncapi-bot + MERGE_LABELS: "" + MERGE_METHOD: "squash" + MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" + MERGE_RETRIES: "20" + MERGE_RETRY_SLEEP: "30000" diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml new file mode 100644 index 0000000..c7635c1 --- /dev/null +++ b/.github/workflows/autoupdate.yml @@ -0,0 +1,37 @@ +# 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: + branches-ignore: + - 'version-bump/**' + - '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: + - name: Autoupdating + uses: docker://chinthakagodawita/autoupdate-action:v1 + env: + GITHUB_TOKEN: '${{ secrets.GH_TOKEN }}' + PR_FILTER: "labelled" + PR_LABELS: "autoupdate" + PR_READY_STATE: "ready_for_review" + MERGE_CONFLICT_ACTION: "ignore" diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 0000000..68daa7c --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,34 @@ +# 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-in-dependent-projects: + name: Bump this package in repositories that depend on it + if: startsWith(github.event.commits[0].message, 'chore(release):') + 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' + name: Bumping latest version of this package in other repositories + uses: derberg/npm-dependency-manager-for-your-github-org@v4 + with: + github_token: ${{ secrets.GH_TOKEN }} + committer_username: asyncapi-bot + committer_email: info@asyncapi.io + repos_to_ignore: html-template # this is temporary until react component releases 1.0, then it can be removed diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml new file mode 100644 index 0000000..16f378c --- /dev/null +++ b/.github/workflows/help-command.yml @@ -0,0 +1,44 @@ +# 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_pr: + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }} + 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 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 + - `/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 + 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` diff --git a/.github/workflows/if-go-pr-testing.yml b/.github/workflows/if-go-pr-testing.yml new file mode 100644 index 0000000..606e689 --- /dev/null +++ b/.github/workflows/if-go-pr-testing.yml @@ -0,0 +1,69 @@ +# 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: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + +jobs: + lint-go-pr: + name: Lint Go PR + runs-on: ubuntu-latest + steps: + - if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))" + id: should_run + name: Should Run + run: echo "::set-output name=shouldrun::true" + - if: steps.should_run.outputs.shouldrun == 'true' + name: Checkout repository + uses: actions/checkout@v2 + - if: steps.should_run.outputs.shouldrun == 'true' + name: Check if Go project and has go.mod + id: gomod + run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + shell: bash + - if: steps.gomod.outputs.exists == 'true' + name: Setup Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16 + - if: steps.gomod.outputs.exists == 'true' + name: golangci-lint + uses: golangci/golangci-lint-action@v2 # golangci-lint version extracted from go.mod. `latest` if missing. + with: + skip-go-installation: true # we wanna control the version of Go in use + + test-go-pr: + name: Test Go PR - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))" + id: should_run + name: Should Run + run: echo "::set-output name=shouldrun::true" + - if: steps.should_run.outputs.shouldrun == 'true' + name: Checkout repository + uses: actions/checkout@v2 + - if: steps.should_run.outputs.shouldrun == 'true' + name: Check if Go project and has go.mod + id: gomod + run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + shell: bash + - if: steps.gomod.outputs.exists == 'true' + name: Setup Go + uses: actions/setup-go@v2.1.3 + with: + go-version: 1.16 + - if: steps.gomod.outputs.exists == 'true' + name: Build + run: go build -v ./... + - if: steps.gomod.outputs.exists == 'true' + name: Test + run: go test -v ./... + diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml new file mode 100644 index 0000000..1dcccd3 --- /dev/null +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -0,0 +1,61 @@ +# 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: + pull_request: + types: [opened, reopened, synchronize, ready_for_review] + +jobs: + test-nodejs-pr: + name: Test NodeJS PR - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))" + id: should_run + name: Should Run + run: echo "::set-output name=shouldrun::true" + - if: steps.should_run.outputs.shouldrun == 'true' + name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - if: steps.should_run.outputs.shouldrun == 'true' + name: Checkout repository + uses: actions/checkout@v2 + - if: steps.should_run.outputs.shouldrun == 'true' + 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" + shell: bash + - if: steps.packagejson.outputs.exists == 'true' + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' + name: Install dependencies + id: first-installation + run: npm install --loglevel verbose + continue-on-error: true + - if: steps.first-installation.outputs.status == 'failure' && steps.packagejson.outputs.exists == 'true' + name: Clear NPM cache and install deps again + run: | + npm cache clean --force + npm install --loglevel verbose + - if: steps.packagejson.outputs.exists == 'true' + name: Test + run: npm test + - if: steps.packagejson.outputs.exists == 'true' + name: Run linter + run: npm run lint + - if: steps.packagejson.outputs.exists == 'true' + name: Run release assets generation to make sure PR does not break it + run: npm run generate:assets diff --git a/.github/workflows/if-nodejs-release.yml b/.github/workflows/if-nodejs-release.yml new file mode 100644 index 0000000..bc5b537 --- /dev/null +++ b/.github/workflows/if-nodejs-release.yml @@ -0,0 +1,86 @@ +# 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: + push: + branches: + - master + # below lines are not enough to have release supported for these branches + # make sure configuration of `semantic-release` package mentiones these branches + - next + - next-major + - beta + - alpha + - '**-release' # custom + +jobs: + + test-nodejs: + name: Test NodeJS release on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - name: Checkout repository + 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" + shell: bash + - if: steps.packagejson.outputs.exists == 'true' + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 14 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' + name: Install dependencies + run: npm install + - if: steps.packagejson.outputs.exists == 'true' + name: Run test + run: npm test + + release: + needs: [test-nodejs] + name: Publish to any of NPM, Github, and Docker Hub + runs-on: ubuntu-latest + steps: + - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - name: Checkout repository + 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' + name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 14 + - if: steps.packagejson.outputs.exists == 'true' + name: Install dependencies + run: npm install + - if: steps.packagejson.outputs.exists == 'true' + name: Publish to any of NPM, Github, and Docker Hub + id: release + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + GIT_AUTHOR_NAME: asyncapi-bot + GIT_AUTHOR_EMAIL: info@asyncapi.io + GIT_COMMITTER_NAME: asyncapi-bot + GIT_COMMITTER_EMAIL: info@asyncapi.io + run: npm run release diff --git a/.github/workflows/if-nodejs-version-bump.yml b/.github/workflows/if-nodejs-version-bump.yml new file mode 100644 index 0000000..721caa9 --- /dev/null +++ b/.github/workflows/if-nodejs-version-bump.yml @@ -0,0 +1,49 @@ +# 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 NodeJS + 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 + author: asyncapi-bot + 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}} \ No newline at end of file diff --git a/.github/workflows/issues-prs-notifications.yml b/.github/workflows/issues-prs-notifications.yml new file mode 100644 index 0000000..576b2ba --- /dev/null +++ b/.github/workflows/issues-prs-notifications.yml @@ -0,0 +1,72 @@ +# 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 +name: Notify slack + +on: + + issues: + types: [opened, reopened] + + pull_request_target: + types: [opened, reopened, ready_for_review] + + discussion: + types: [created] + +jobs: + + issue: + if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' + name: Notify slack on every new issue + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown for issue + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: issuemarkdown + with: + text: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}" + - name: Send info about issue + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} + SLACK_TITLE: πŸ› New Issue in ${{github.repository}} πŸ› + SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} + MSG_MINIMAL: true + + pull_request: + if: github.event_name == 'pull_request_target' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' + name: Notify slack on every new pull request + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown for pull request + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: prmarkdown + with: + text: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}" + - name: Send info about pull request + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} + SLACK_TITLE: πŸ’ͺ New Pull Request in ${{github.repository}} πŸ’ͺ + SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}} + MSG_MINIMAL: true + + discussion: + if: github.event_name == 'discussion' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' + name: Notify slack on every new pull request + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown for pull request + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: discussionmarkdown + with: + text: "[${{github.event.discussion.title}}](${{github.event.discussion.html_url}}) \n ${{github.event.discussion.body}}" + - name: Send info about pull request + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} + SLACK_TITLE: πŸ’¬ New Discussion in ${{github.repository}} πŸ’¬ + SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}} + MSG_MINIMAL: true diff --git a/.github/workflows/link-check-cron.yml b/.github/workflows/link-check-cron.yml new file mode 100644 index 0000000..2b7038a --- /dev/null +++ b/.github/workflows/link-check-cron.yml @@ -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 + +name: Check Markdown links (Weekly) + +on: + workflow_dispatch: + schedule: + # At 00:00 UTC on every Monday + - cron: '0 0 * * 0' + +jobs: + External-link-validation-weekly: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + # Checks the status of hyperlinks in .md files + - name: Check links + uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + use-quiet-mode: 'yes' + use-verbose-mode: 'yes' + + - name: Report workflow run status to Slack + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,action,eventName,ref,workflow + env: + SLACK_DOCS_CHANNEL: ${{ secrets.SLACK_DOCS_CHANNEL }} + if: failure() # Only, on failure, send a message on the Slack Docs Channel (if there are broken links) diff --git a/.github/workflows/link-check-pr.yml b/.github/workflows/link-check-pr.yml new file mode 100644 index 0000000..2d7fec3 --- /dev/null +++ b/.github/workflows/link-check-pr.yml @@ -0,0 +1,20 @@ +# 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: + pull_request_target: + types: [synchronize, ready_for_review, opened, reopened] + +jobs: + External-link-validation-on-PR: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check links + uses: gaurav-nelson/github-action-markdown-link-check@v1 + with: + use-quiet-mode: 'yes' + use-verbose-mode: 'yes' + check-modified-files-only: 'yes' #Only modified files are checked on PRs diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..87e2fa5 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,23 @@ +# 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 + +on: + pull_request_target: + types: [opened, reopened, synchronize, edited, ready_for_review] + +jobs: + lint-pr-title: + name: Lint PR title + runs-on: ubuntu-latest + steps: + # Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level. + - if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }} + uses: amannn/action-semantic-pull-request@v3.2.5 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + subjectPattern: ^(?![A-Z]).+$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character. diff --git a/.github/workflows/notify-tsc-members-mention.yml b/.github/workflows/notify-tsc-members-mention.yml new file mode 100644 index 0000000..e33b262 --- /dev/null +++ b/.github/workflows/notify-tsc-members-mention.yml @@ -0,0 +1,142 @@ +# 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 +name: Notify slack whenever TSC members are mentioned in GitHub + +on: + issue_comment: + types: + - created + - edited + + discussion_comment: + types: + - created + - edited + + issues: + types: + - opened + - reopened + + pull_request_target: + types: + - opened + - reopened + - ready_for_review + + discussion: + types: + - created + - edited + +jobs: + + issue: + if: github.event_name == 'issues' && contains(github.event.issue.body, '@asyncapi/tsc_members') + name: TSC notification on every new issue + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: issuemarkdown + with: + text: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}" + - name: Send info about issue + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New issue that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} + MSG_MINIMAL: true + + pull_request: + if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.body, '@asyncapi/tsc_members') + name: TSC notification on every new pull request + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: prmarkdown + with: + text: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}" + - name: Send info about pull request + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New PR that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}} + MSG_MINIMAL: true + + discussion: + if: github.event_name == 'discussion' && contains(github.event.discussion.body, '@asyncapi/tsc_members') + name: TSC notification on every new discussion + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: discussionmarkdown + with: + text: "[${{github.event.discussion.title}}](${{github.event.discussion.html_url}}) \n ${{github.event.discussion.body}}" + - name: Send info about pull request + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New discussion that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}} + MSG_MINIMAL: true + + issue_comment: + if: ${{ github.event_name == 'issue_comment' && !github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members') }} + name: TSC notification on every new comment in issue + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: issuemarkdown + with: + text: "[${{github.event.issue.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}" + - name: Send info about issue comment + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New comment under existing issue that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} + MSG_MINIMAL: true + + pr_comment: + if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members') + name: TSC notification on every new comment in pr + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: prmarkdown + with: + text: "[${{github.event.issue.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}" + - name: Send info about PR comment + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New comment under existing PR that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}} + MSG_MINIMAL: true + + discussion_comment: + if: github.event_name == 'discussion_comment' && contains(github.event.comment.body, '@asyncapi/tsc_members') + name: TSC notification on every new comment in discussion + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: discussionmarkdown + with: + text: "[${{github.event.discussion.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}" + - name: Send info about discussion comment + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}} + SLACK_TITLE: πŸ†˜ New comment under existing discussion that requires TSC Members attention πŸ†˜ + SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}} + MSG_MINIMAL: true \ No newline at end of file diff --git a/.github/workflows/release-announcements.yml b/.github/workflows/release-announcements.yml new file mode 100644 index 0000000..b2f3ba7 --- /dev/null +++ b/.github/workflows/release-announcements.yml @@ -0,0 +1,77 @@ +# 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: + release: + types: + - published + +jobs: + + slack-announce: + name: Slack - notify on every release + runs-on: ubuntu-latest + steps: + - name: Convert markdown to slack markdown for issue + uses: LoveToKnow/slackify-markdown-action@v1.0.0 + id: markdown + with: + text: "[${{github.event.release.tag_name}}](${{github.event.release.html_url}}) \n ${{ github.event.release.body }}" + - name: Send info about release to Slack + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES }} + SLACK_TITLE: Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱πŸ’ͺπŸΎπŸŽ‚ + SLACK_MESSAGE: ${{steps.markdown.outputs.text}} + MSG_MINIMAL: true + + twitter-announce: + name: Twitter - notify on minor and major releases + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Get version of last and previous release + uses: actions/github-script@v3 + id: versions + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const query = `query($owner:String!, $name:String!) { + repository(owner:$owner, name:$name){ + releases(first: 2, orderBy: {field: CREATED_AT, direction: DESC}) { + nodes { + name + } + } + } + }`; + const variables = { + owner: context.repo.owner, + name: context.repo.repo + }; + const { repository: { releases: { nodes } } } = await github.graphql(query, variables); + core.setOutput('lastver', nodes[0].name); + // In case of first release in the package, there is no such thing as previous error, so we set info about previous version only once we have it + // We should tweet about the release no matter of the type as it is initial release + if (nodes.length != 1) core.setOutput('previousver', nodes[1].name); + - name: Identify release type + id: releasetype + # if previousver is not provided then this steps just logs information about missing version, no errors + run: echo "::set-output name=type::$(npx -q -p semver-diff-cli semver-diff ${{steps.versions.outputs.previousver}} ${{steps.versions.outputs.lastver}})" + - name: Get name of the person that is behind the newly released version + id: author + run: echo "::set-output name=name::$(git log -1 --pretty=format:'%an')" + - name: Publish information about the release to Twitter # tweet only if detected version change is not a patch + # tweet goes out even if the type is not major or minor but "You need provide version number to compare." + # it is ok, it just means we did not identify previous version as we are tweeting out information about the release for the first time + if: steps.releasetype.outputs.type != 'null' && steps.releasetype.outputs.type != 'patch' # null means that versions are the same + uses: m1ner79/Github-Twittction@v1.0.1 + with: + twitter_status: "Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱πŸ’ͺπŸΎπŸŽ‚\n\nThank you for the contribution ${{ steps.author.outputs.name }} ${{github.event.release.html_url}}" + twitter_consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }} + twitter_consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }} + twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }} + twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} \ No newline at end of file diff --git a/.github/workflows/sentiment-analysis.yml b/.github/workflows/sentiment-analysis.yml new file mode 100644 index 0000000..cd8ab05 --- /dev/null +++ b/.github/workflows/sentiment-analysis.yml @@ -0,0 +1,45 @@ +# 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' + +on: + issue_comment: + types: + - created + - edited + issues: + types: + - opened + - edited + pull_request: + types: + - opened + - edited + pull_request_review: + types: + - submitted + - edited + pull_request_review_comment: + types: + - created + - edited +jobs: + sentiments: + if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }} + name: Checking sentiments + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check sentiment + uses: derberg/code-of-conduct-sentiment-analysis-github-action@v1 + id: sentiments + with: + gcp_key: ${{ secrets.GCP_KEY_SENTIMENT }} + - uses: someimportantcompany/github-actions-slack-message@v1 + # this step runs only if sentiment is a negative number + if: steps.sentiments.outputs.sentiment < -0.6 + with: + webhook-url: ${{ secrets.SLACK_SENTIMENTS }} + text: Here ${{steps.sentiments.outputs.source}} you can find a potential negative text that requires your attention as the sentiment analysis score is ${{steps.sentiments.outputs.sentiment}} + color: orange \ No newline at end of file diff --git a/.github/workflows/stale-issues-prs.yml b/.github/workflows/stale-issues-prs.yml new file mode 100644 index 0000000..7667318 --- /dev/null +++ b/.github/workflows/stale-issues-prs.yml @@ -0,0 +1,43 @@ +# 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 + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + name: Mark issue or PR as stale + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v4.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: | + This issue has been automatically marked as stale because it has not had recent activity :sleeping: + + It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. + + There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). + + Let us figure out together how to push this issue forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. + + Thank you for your patience :heart: + stale-pr-message: | + This pull request has been automatically marked as stale because it has not had recent activity :sleeping: + + It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. + + There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). + + Let us figure out together how to push this pull request forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. + + Thank you for your patience :heart: + days-before-stale: 120 + days-before-close: 120 + stale-issue-label: stale + stale-pr-label: stale + exempt-issue-labels: keep-open + exempt-pr-labels: keep-open \ No newline at end of file diff --git a/.github/workflows/welcome-first-time-contrib.yml b/.github/workflows/welcome-first-time-contrib.yml new file mode 100644 index 0000000..e72fece --- /dev/null +++ b/.github/workflows/welcome-first-time-contrib.yml @@ -0,0 +1,85 @@ +# 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: Welcome first time contributors + +on: + pull_request_target: + types: + - opened + issues: + types: + - opened + +jobs: + welcome: + name: Post welcome message + if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors"]'), github.actor) }} + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issueMessage = `Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) and the instructions about a [basic recommended setup](https://github.com/asyncapi/.github/blob/master/git-workflow.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; + const prMessage = `Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; + if (!issueMessage && !prMessage) { + throw new Error('Action must have at least one of issue-message or pr-message set'); + } + const isIssue = !!context.payload.issue; + let isFirstContribution; + if (isIssue) { + const query = `query($owner:String!, $name:String!, $contributer:String!) { + repository(owner:$owner, name:$name){ + issues(first: 1, filterBy: {createdBy:$contributer}){ + totalCount + } + } + }`; + const variables = { + owner: context.repo.owner, + name: context.repo.repo, + contributer: context.payload.sender.login + }; + const { repository: { issues: { totalCount } } } = await github.graphql(query, variables); + isFirstContribution = totalCount === 1; + } else { + const query = `query($qstr: String!) { + search(query: $qstr, type: ISSUE, first: 1) { + issueCount + } + }`; + const variables = { + "qstr": `repo:${context.repo.owner}/${context.repo.repo} type:pr author:${context.payload.sender.login}`, + }; + const { search: { issueCount } } = await github.graphql(query, variables); + isFirstContribution = issueCount === 1; + } + + if (!isFirstContribution) { + console.log(`Not the users first contribution.`); + return; + } + const message = isIssue ? issueMessage : prMessage; + // Add a comment to the appropriate place + if (isIssue) { + const issueNumber = context.payload.issue.number; + console.log(`Adding message: ${message} to issue #${issueNumber}`); + await github.issues.createComment({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + issue_number: issueNumber, + body: message + }); + } + else { + const pullNumber = context.payload.pull_request.number; + console.log(`Adding message: ${message} to pull request #${pullNumber}`); + await github.pulls.createReview({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + pull_number: pullNumber, + body: message, + event: 'COMMENT' + }); + }