action: GitHub command for new PRs created by the APM UI/Oblt teams (#153433)

## Summary

Make sure the `apm-ui`/`observability` teams are ware of the new
features, such as https://github.com/elastic/kibana/pull/153106

For such, this new action will create a GitHub comment only when a PR is
created by any member of `observability` team.

The comment will be something like:

<img width="1185" alt="image"
src="https://user-images.githubusercontent.com/2871786/226889581-58d9962d-93f0-400e-9b82-3ba12f84c4fe.png">

cc @elastic/apm-ui @cachedout @kuisathaverat

---------

Co-authored-by: Ivan Fernandez Calvo <kuisathaverat@users.noreply.github.com>
This commit is contained in:
Victor Martinez 2023-03-23 09:34:44 +01:00 committed by GitHub
parent 83ec37fe23
commit fa74940809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 0 deletions

1
.github/CODEOWNERS vendored
View file

@ -778,6 +778,7 @@ packages/kbn-yarn-lock-validator @elastic/kibana-operations
# Observability robots
/.github/workflows/deploy-my-kibana.yml @elastic/observablt-robots
/.github/workflows/oblt-github-commands @elastic/observablt-robots
# Infra Monitoring
/x-pack/test/functional/apps/infra @elastic/infra-monitoring-ui

View file

@ -0,0 +1,63 @@
---
##
## This the automation to let Observability team members to know what are the
## supported GitHub commands to interact with the Observability test environments.
##
## Owner: @elastic/observablt-robots
##
name: oblt-github-commands
on:
pull_request_target:
types:
- opened
permissions:
contents: read
jobs:
comment-if-oblt-member:
runs-on: ubuntu-latest
steps:
- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
with:
url: ${{ secrets.OBLT_VAULT_ADDR }}
roleId: ${{ secrets.OBLT_VAULT_ROLE_ID }}
secretId: ${{ secrets.OBLT_VAULT_SECRET_ID }}
- id: is_team_member
name: Check if user is member of the Elastic org and Observability team
run: |
if gh api -H "Accept: application/vnd.github+json" \
/orgs/elastic/teams/observability/memberships/${{ github.actor }} ; then
echo "result=true" >> $GITHUB_OUTPUT
else
echo "result=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
- if: ${{ steps.is_team_member.outputs.result == 'true' }}
uses: actions/github-script@v6
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const body = `
### :robot: GitHub comments
<details><summary>Expand to view the GitHub comments</summary>
<p>
Just comment with:
- \`/oblt-deploy\` : Deploy a Kibana instance using the Observability test environments.
- \`run\` \`elasticsearch-ci/docs\` : Re-trigger the docs validation. (use unformatted text in the comment!)
</p>
</details>
`.replace(/ +/g, '')
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})