Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 2b404ff

Browse files
asyncapi-botasyncapi-botderberg
authored
ci: update global workflows (#38)
Co-authored-by: asyncapi-bot <[email protected]> Co-authored-by: Lukasz Gornicki <[email protected]>
1 parent aaf0b56 commit 2b404ff

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#This action is centrally managed in https://github.com/asyncapi/.github/
2+
#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
3+
name: Notify slack
4+
5+
on:
6+
7+
issues:
8+
types: [opened, reopened]
9+
10+
pull_request_target:
11+
types: [opened, reopened, ready_for_review]
12+
13+
jobs:
14+
15+
issue:
16+
if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
17+
name: On every new issue
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Convert markdown to slack markdown for issue
21+
uses: LoveToKnow/[email protected]
22+
id: issuemarkdown
23+
with:
24+
text: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}"
25+
- name: Send info about issue
26+
uses: rtCamp/action-slack-notify@v2
27+
env:
28+
SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}}
29+
SLACK_TITLE: 🐛 New Issue 🐛
30+
SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}}
31+
MSG_MINIMAL: true
32+
33+
pull_request:
34+
if: github.event_name == 'pull_request_target' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
35+
name: On every new pull request
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Convert markdown to slack markdown for pull request
39+
uses: LoveToKnow/[email protected]
40+
id: prmarkdown
41+
with:
42+
text: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}"
43+
- name: Send info about pull request
44+
uses: rtCamp/action-slack-notify@v2
45+
env:
46+
SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}}
47+
SLACK_TITLE: 💪 New Pull Request 💪
48+
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
49+
MSG_MINIMAL: true
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#This action is centrally managed in https://github.com/asyncapi/.github/
2+
#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
3+
name: 'Announce releases in different channels'
4+
5+
on:
6+
release:
7+
types:
8+
- published
9+
10+
jobs:
11+
12+
slack:
13+
name: Slack - notify on every release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Convert markdown to slack markdown for issue
17+
uses: LoveToKnow/[email protected]
18+
id: markdown
19+
with:
20+
text: "[${{github.event.release.tag_name}}](${{github.event.release.html_url}}) \n ${{ github.event.release.body }}"
21+
- name: Send info about release to Slack
22+
uses: rtCamp/action-slack-notify@v2
23+
env:
24+
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES }}
25+
SLACK_TITLE: Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂
26+
SLACK_MESSAGE: ${{steps.markdown.outputs.text}}
27+
MSG_MINIMAL: true
28+
29+
twitter:
30+
name: Twitter - notify on minor and major releases
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout repo
34+
uses: actions/checkout@v2
35+
- name: Get version of last and previous release
36+
uses: actions/github-script@v3
37+
id: versions
38+
with:
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
script: |
41+
const query = `query($owner:String!, $name:String!) {
42+
repository(owner:$owner, name:$name){
43+
releases(first: 2, orderBy: {field: CREATED_AT, direction: DESC}) {
44+
nodes {
45+
name
46+
}
47+
}
48+
}
49+
}`;
50+
const variables = {
51+
owner: context.repo.owner,
52+
name: context.repo.repo
53+
};
54+
const { repository: { releases: { nodes } } } = await github.graphql(query, variables);
55+
core.setOutput('lastver', nodes[0].name);
56+
// 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
57+
// We should tweet about the release no matter of the type as it is initial release
58+
if (nodes.length != 1) core.setOutput('previousver', nodes[1].name);
59+
- name: Identify release type
60+
id: releasetype
61+
# if previousver is not provided then this steps just logs information about missing version, no errors
62+
run: echo "::set-output name=type::$(npx -q -p semver-diff-cli semver-diff ${{steps.versions.outputs.previousver}} ${{steps.versions.outputs.lastver}})"
63+
- name: Get name of the person that is behind the newly released version
64+
id: author
65+
run: echo "::set-output name=name::$(git log -1 --pretty=format:'%an')"
66+
- name: Publish information about the release to Twitter # tweet only if detected version change is not a patch
67+
# tweet goes out even if the type is not major or minor but "You need provide version number to compare."
68+
# 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
69+
if: steps.releasetype.outputs.type != 'null' && steps.releasetype.outputs.type != 'patch' # null means that versions are the same
70+
uses: m1ner79/[email protected]
71+
with:
72+
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}}"
73+
twitter_consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }}
74+
twitter_consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
75+
twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
76+
twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

0 commit comments

Comments
 (0)