This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Issue Opened Action | |
on: | |
issues: | |
types: [opened] | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Get vault secrets" | |
id: vault-secrets | |
uses: grafana/shared-workflows/actions/get-vault-secrets@main | |
with: | |
# Secrets placed in the ci/repo/grafana/<repo>/<path> path in Vault | |
repo_secrets: | | |
APP_ID=triager_bot_github:app_id | |
APP_PEM=triager_bot_github:app_pem | |
- name: "Generate token" | |
id: generate_token | |
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 | |
with: | |
app_id: ${{ env.APP_ID }} | |
private_key: ${{ env.APP_PEM }} | |
- name: Check org membership | |
id: check_membership | |
run: | | |
RESPONSE=$(curl -s -X POST \ | |
-H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \ | |
-H "Content-Type: application/json" \ | |
https://api.github.com/graphql \ | |
-d "{ | |
\"query\": \"query { user(login: \\\"adela-almasan\\\") { organization(login: \\\"grafana\\\") { id } } }\" | |
}") | |
# Use select to safely navigate the response | |
if echo "$RESPONSE" | jq -e '.data.user?.organization?.id != null' > /dev/null; then | |
echo "is_member=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "is_member=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Debug membership status | |
run: | | |
echo "Checking membership for user: ${{ github.event.issue.user.login }}" | |
echo "Raw API response: $RESPONSE" | |
if [ "${{ steps.check_membership.outputs.is_member }}" = "true" ]; then | |
echo "✅ User ${{ github.event.issue.user.login }} is a member of the organization" | |
else | |
echo "❌ User ${{ github.event.issue.user.login }} is NOT a member of the organization" | |
fi |