Skip to content

Commit 2a23b3b

Browse files
p3dr0rvCopilot
andauthored
Add GitHub Actions workflow to notify on changes to versions.gradle, Fixes AB#1234567 (#2829)
This pull request introduces improvements to GitHub Actions workflows to enhance automation and reliability around Gradle version changes and AB ID extraction from pull requests. The main changes include the addition of a new workflow for monitoring updates to the `gradle/versions.gradle` file and a more robust method for extracting AB IDs from PR bodies. **Workflow automation enhancements:** * Added a new workflow `.github/workflows/gradle-versions-watcher.yml` that triggers on changes to `gradle/versions.gradle` in the `dev` and `release/**` branches, logging changes and commenting on pull requests with a warning and documentation link. **Improved AB ID extraction logic:** * Updated the `validate-pr-ab-id.yml` workflow to sanitize the pull request body by removing backticks and to extract the AB ID using the pattern `[[AB#1234567](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/1234567)]` instead of just `#1234567`, improving reliability and accuracy. [AB#3424644](https://identitydivision.visualstudio.com/fac9d424-53d2-45c0-91b5-ef6ba7a6bf26/_workitems/edit/3424644) --------- Co-authored-by: Copilot <[email protected]>
1 parent cd2900f commit 2a23b3b

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Notify on versions.gradle changes
2+
3+
on:
4+
push:
5+
paths:
6+
- 'gradle/versions.gradle'
7+
branches:
8+
- dev
9+
- 'release/**'
10+
pull_request:
11+
paths:
12+
- 'gradle/versions.gradle'
13+
branches:
14+
- dev
15+
- 'release/**'
16+
17+
permissions:
18+
pull-requests: write
19+
20+
jobs:
21+
notify:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Log changes
25+
run: |
26+
echo "Changes detected in the 'gradle/versions.gradle' file."
27+
28+
- name: Comment on PR
29+
if: github.event_name == 'pull_request'
30+
uses: mshick/add-pr-comment@v2
31+
with:
32+
message: "⚠️ **Warning:** Changes detected in the 'versions.gradle' file! ⚠️\n\nPlease refer to [this document](https://dev.azure.com/IdentityDivision/IdentityWiki/_wiki/wikis/IdentityWiki.wiki/82085/Adding-or-Updating-Gradle-Dependencies) for more details."

.github/workflows/validate-pr-ab-id.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ jobs:
3333
# Extracts the AB ID from the pull_request body using regex and store the result using outputs
3434
- name: Get AB ID from comment
3535
id: get
36+
env:
37+
PR_BODY: ${{ github.event.pull_request.body }}
3638
run: |
37-
result=$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=#)\d+')
38-
echo "id=${result}" >> "$GITHUB_OUTPUT"
39+
# Sanitize PR body by removing backticks to prevent command substitution
40+
clean=$(printf "%s" "$PR_BODY" | tr -d '`')
41+
42+
# Extract AB ID (AB#1234567) - takes first match if multiple exist
43+
result=$(printf "%s" "$clean" | grep -oP '(?<=AB#)\d+' | head -n 1)
44+
45+
echo "id=$result" >> "$GITHUB_OUTPUT"
3946

4047
# Get Pull request ID
4148
get_pr_id:

gradle/versions.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Variables for entire project
1+
// Variables for entire project.
22
// Taken from android-complete.
33
ext {
44
// SDK

0 commit comments

Comments
 (0)