Skip to content

Commit

Permalink
ci: update global workflows (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: asyncapi-bot <info@asyncapi.io>
  • Loading branch information
asyncapi-bot and asyncapi-bot committed Apr 22, 2021
1 parent 4f9473a commit b9c192e
Show file tree
Hide file tree
Showing 12 changed files with 572 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/automerge-orphans.yml
@@ -0,0 +1,64 @@
#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){
nodes{
title
url
author {
resourcePath
}
state
}
}
}
}`;
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.state === 'OPEN' && (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
47 changes: 47 additions & 0 deletions .github/workflows/automerge.yml
@@ -0,0 +1,47 @@
#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:
- labeled
- unlabeled
- synchronize
- opened
- edited
- ready_for_review
- reopened
- unlocked
pull_request_review:
types:
- submitted

jobs:

autoapprove:
if: github.event.pull_request.draft == false
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]'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

automerge:
needs: [autoapprove]
runs-on: ubuntu-latest
steps:
- name: Automerging
uses: pascalgn/automerge-action@v0.13.0
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: "20000"
58 changes: 58 additions & 0 deletions .github/workflows/if-go-pr-testing.yml
@@ -0,0 +1,58 @@
#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:
if: github.event.pull_request.draft == false
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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:
if: github.event.pull_request.draft == false
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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 ./...

41 changes: 41 additions & 0 deletions .github/workflows/if-nodejs-pr-testing.yml
@@ -0,0 +1,41 @@
#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:
if: github.event.pull_request.draft == false
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- 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@v1
with:
node-version: 14
- if: steps.packagejson.outputs.exists == 'true'
name: Install dependencies
run: 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
66 changes: 66 additions & 0 deletions .github/workflows/if-nodejs-release.yml
@@ -0,0 +1,66 @@
#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

jobs:

test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- 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@v1
with:
node-version: 14
- 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
name: Publish to NPM and GitHub
runs-on: ubuntu-latest
steps:
- 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: Release to NPM and GitHub
id: release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
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
45 changes: 45 additions & 0 deletions .github/workflows/if-nodejs-version-bump.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
#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 repo
uses: actions/checkout@v2
with:
ref: master
- 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 <info@asyncapi.io>
author: asyncapi-bot <info@asyncapi.io>
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}}
49 changes: 49 additions & 0 deletions .github/workflows/issues-prs-notifications.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
name: Notify slack

on:

issues:
types: [opened, reopened]

pull_request_target:
types: [opened, reopened, ready_for_review]

jobs:

issue:
if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
name: 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 🐛
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: 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 💪
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
MSG_MINIMAL: true

0 comments on commit b9c192e

Please sign in to comment.