Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore: intiialize the repository #1

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/automerge-orphans.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
Original file line number Diff line number Diff line change
@@ -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]') && !contains(github.event.pull_request.labels.*.name, 'released')
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

automerge:
needs: [autoapprove]
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"
32 changes: 32 additions & 0 deletions .github/workflows/bump.yml
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
58 changes: 58 additions & 0 deletions .github/workflows/if-go-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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 ./...

50 changes: 50 additions & 0 deletions .github/workflows/if-nodejs-pr-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#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@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
72 changes: 72 additions & 0 deletions .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
@@ -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
#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
- '**-release'

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@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
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: [email protected]
GIT_COMMITTER_NAME: asyncapi-bot
GIT_COMMITTER_EMAIL: [email protected]
run: npm run release
48 changes: 48 additions & 0 deletions .github/workflows/if-nodejs-version-bump.yml
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}}
Loading