From 02967961f39033d1eba93b0ffe15730636234b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Wed, 2 Jul 2025 19:49:00 -0700 Subject: [PATCH] fix: use triggering user's email/name in draft-release workflow (#22229) Co-authored-by: zomars@cal.com Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/workflows/draft-release.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 09520a0676..40ab791c4e 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -27,8 +27,24 @@ jobs: - name: Configure git run: | - git config --local user.email "github-actions@github.com" - git config --local user.name "GitHub Actions" + # Define authorized users and their emails using organization secret + # Expected format: JSON object with username -> email mapping + # Example: {"zomars": "zomars@cal.com", "peer": "peer@cal.com", "username3": "email3@cal.com"} + USER_EMAILS='${{ secrets.RELEASE_USER_EMAILS }}' + + # Extract email for the triggering user + USER_EMAIL=$(echo "$USER_EMAILS" | jq -r --arg user "${{ github.actor }}" '.[$user] // empty') + + # Fail if user is not authorized or not in mapping + if [ -z "$USER_EMAIL" ] || [ "$USER_EMAIL" = "null" ]; then + echo "Error: User '${{ github.actor }}' is not authorized to run the release workflow." + echo "Only authorized team members can trigger releases." + echo "Contact your administrator to be added to the authorized users list." + exit 1 + fi + + git config --local user.email "$USER_EMAIL" + git config --local user.name "${{ github.actor }}" - uses: ./.github/actions/yarn-install