Skip to content

Commit

Permalink
Merge pull request #2008 from hashicorp/w-add-feed-worfklow
Browse files Browse the repository at this point in the history
Add team feed integration for AWSCC
  • Loading branch information
breathingdust authored Sep 12, 2024
2 parents 0d97dee + 7515d5c commit 9c572a6
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/label-notifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Handle Label Notifications
permissions: {}

on:
issues:
types:
- labeled

pull_request_target:
types:
- labeled

jobs:
process:
name: Process Label
if: github.event.label.name == 'regression' || github.event.label.name == 'crash'
runs-on: ubuntu-latest

env:
ISSUE_URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}

steps:
- name: Send Slack Notification
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
env:
ISSUE_TITLE: ${{ toJSON(github.event.issue.title || github.event.pull_request.title) }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: ${{ secrets.SLACK_CHANNEL }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":warning: [AWSCC] The following has been labeled as a ${{ github.event.label.name }}:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(format('<{0}|{1}>', env.ISSUE_URL, env.ISSUE_TITLE)) }}
}
}
]
}
- name: Generate GitHub App Token
id: token
uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PEM }}

- name: Move to the Top of the Team Working Board
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
run: |
PROJECT_ITEM_ID=$(gh project item-add 196 --owner "hashicorp" --url "$ISSUE_URL" --format json --jq '.id')
gh project item-edit \
--id "$PROJECT_ITEM_ID" \
--project-id "PVT_kwDOAAuecM4AF-7h" \
--field-id "PVTSSF_lADOAAuecM4AF-7hzgMRB34" \
--single-select-option-id "${{ vars.team_project_view_working_board }}"
gh api graphql \
-F itemId="$PROJECT_ITEM_ID" \
-F projectId="PVT_kwDOAAuecM4AF-7h" \
-f query='mutation($itemId:ID!, $projectId:ID!) {
updateProjectV2ItemPosition(input:{itemId:$itemId, projectId:$projectId}) {
clientMutationId
}
}'
97 changes: 97 additions & 0 deletions .github/workflows/pull_request_feed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Pull Request Feed

on:
pull_request_target:
types: [opened, closed]

permissions:
contents: read

env:
SLACK_WEBHOOK_URL: ${{ secrets.FEED_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
PR_HTML_URL: ${{ github.event.pull_request.html_url }}
PR_TITLE: ${{ github.event.pull_request.title }}

jobs:
feed:
name: Slack Notifications
runs-on: ubuntu-latest
steps:
- name: Checkout Community Check
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
sparse-checkout: .github/actions/community_check

- name: Run Community Check
id: community_check
uses: ./.github/actions/community_check
with:
user_login: ${{ github.event.pull_request.user.login }}
maintainers: ${{ secrets.MAINTAINERS }}
partners: ${{ secrets.PARTNERS }}

- name: Pull Request Merged
if: github.event.pull_request.merged
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
env:
MERGED_BY_URL: ${{ github.event.pull_request.merged_by.html_url }}
MERGED_BY_LOGIN: ${{ github.event.pull_request.merged_by.login }}
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(format(':merged: [AWSCC] <{0}|{1}> merged <{2}|{3}>', env.MERGED_BY_URL, env.MERGED_BY_LOGIN, env.PR_HTML_URL, env.PR_TITLE)) }}
}
}
]
}
- name: Maintainer Pull Request Opened
if: |
github.event.action == 'opened'
&& steps.community_check.outputs.maintainer == 'true'
&& github.actor != 'dependabot[bot]'
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
env:
PR_AUTHOR_URL: ${{ github.event.pull_request.user.html_url }}
PR_AUTHOR_LOGIN: ${{ github.event.pull_request.user.login }}
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(format(':open: [AWSCC] <{0}|{1}> opened <{2}|{3}>', env.PR_AUTHOR_URL, env.PR_AUTHOR_LOGIN, env.PR_HTML_URL, env.PR_TITLE)) }}
}
}
]
}
- name: Partner Pull Request Opened
if: |
github.event.action == 'opened'
&& steps.community_check.outputs.partner == 'true'
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
env:
PR_AUTHOR_URL: ${{ github.event.pull_request.user.html_url }}
PR_AUTHOR_LOGIN: ${{ github.event.pull_request.user.login }}
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(format(':open: [AWSCC] :aws: contributor <{0}|{1}> opened <{2}|{3}>', env.PR_AUTHOR_URL, env.PR_AUTHOR_LOGIN, env.PR_HTML_URL, env.PR_TITLE)) }}
}
}
]
}
28 changes: 28 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Feed: Release Tag"
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
tag-created:
runs-on: ubuntu-latest
steps:
- name: Notify Slack
id: slack
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":tag: [AWSCC] <https://github.com/${{ github.event.pusher.name }}|${{ github.event.pusher.name }}> pushed tag <https://github.com/hashicorp/terraform-provider-awscc/tree/${{ github.event.ref }}|${{ github.event.ref }}>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.FEED_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 comments on commit 9c572a6

Please sign in to comment.