From a0a89a9d6c9f66c8da866ea05aedb92e8f67e0ac Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Tue, 15 Apr 2025 14:35:05 -0400 Subject: [PATCH 1/4] dataconnect.yml: improve send-notifications message and allow specifying issue via trksmnkncd_notification_issue=6863 in the PR body --- .github/workflows/dataconnect.yml | 50 +++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index f5a58ef6896..a9240d84d77 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -267,19 +267,57 @@ jobs: issues: write runs-on: ubuntu-latest steps: - - name: Post Comment on Issue #6857 - if: github.event_name == 'schedule' + - id: issue-id + name: Determine GitHub Issue For Commenting + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + set -xv + + # If this job was triggered by a pull request, then check to see if + # the description of the PR specifies a GitHub Issue to which to post + # a comment. The GitHub Issue number is specified by including a line + # of the form "trksmnkncd_notification_issue=6863" in the description. + # Specifying an issue number in this manner is primarily intended for + # debugging/development purposes of the comment-posting logic itself. + # For example, issue number 6863 was specifically created for testing. + # (see https://github.com/firebase/firebase-android-sdk/issues/6863) + readonly pr_number + pr_number=$(echo '${{ github.ref }}' | sed -En 's#^refs/pull/([0-9]+)/merge$#\1#p') + if [[ -n $pr_number ]] ; then + readonly issue_from_pr_body + issue_from_pr_body=$(gh issue view "$pr_number" --json body --jq '.body' | sed -En 's#(\s|^)trksmnkncd_notification_issue=([0-9]+)(\s|$)#\2#p') + fi + + if [[ -v $issue_from_pr_body ]] && [[ -n $issue_from_pr_body ]] ; then + readonly issue="$issue_from_pr_body" + elif [[ '${{ github.event_name }}' == 'schedule' ]] ; then + # See https://github.com/firebase/firebase-android-sdk/issues/6857 + readonly issue=6857 + else + readonly issue= + fi + + echo "issue=$issue" >> "$GITHUB_OUTPUT" + + - name: Post Comment on GitHub Issue + if: steps.issue-id.outputs.issue != '' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euo pipefail cat >message.txt < Date: Tue, 15 Apr 2025 16:45:33 -0400 Subject: [PATCH 2/4] dataconnect.yml: remove `readonly` modifier to fix error: `pr_number: readonly variable` --- .github/workflows/dataconnect.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index a9240d84d77..b321e85662a 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -283,20 +283,18 @@ jobs: # debugging/development purposes of the comment-posting logic itself. # For example, issue number 6863 was specifically created for testing. # (see https://github.com/firebase/firebase-android-sdk/issues/6863) - readonly pr_number pr_number=$(echo '${{ github.ref }}' | sed -En 's#^refs/pull/([0-9]+)/merge$#\1#p') if [[ -n $pr_number ]] ; then - readonly issue_from_pr_body issue_from_pr_body=$(gh issue view "$pr_number" --json body --jq '.body' | sed -En 's#(\s|^)trksmnkncd_notification_issue=([0-9]+)(\s|$)#\2#p') fi if [[ -v $issue_from_pr_body ]] && [[ -n $issue_from_pr_body ]] ; then - readonly issue="$issue_from_pr_body" + issue="$issue_from_pr_body" elif [[ '${{ github.event_name }}' == 'schedule' ]] ; then # See https://github.com/firebase/firebase-android-sdk/issues/6857 - readonly issue=6857 + issue=6857 else - readonly issue= + issue= fi echo "issue=$issue" >> "$GITHUB_OUTPUT" From 97229fb2dc943a7b3100de5d7a113525d6f8150f Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Tue, 15 Apr 2025 17:01:45 -0400 Subject: [PATCH 3/4] dataconnect.yml: add `-R ${{ github.repository }}` to `gh` command line --- .github/workflows/dataconnect.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index b321e85662a..c79338992a6 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -256,6 +256,7 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: show-progress: false + sparse-checkout: '.github/' - uses: docker://rhysd/actionlint:1.7.7 with: args: -color /github/workspace/.github/workflows/dataconnect.yml @@ -285,7 +286,7 @@ jobs: # (see https://github.com/firebase/firebase-android-sdk/issues/6863) pr_number=$(echo '${{ github.ref }}' | sed -En 's#^refs/pull/([0-9]+)/merge$#\1#p') if [[ -n $pr_number ]] ; then - issue_from_pr_body=$(gh issue view "$pr_number" --json body --jq '.body' | sed -En 's#(\s|^)trksmnkncd_notification_issue=([0-9]+)(\s|$)#\2#p') + issue_from_pr_body=$(gh issue view "$pr_number" --json body --jq '.body' -R ${{ github.repository }} | sed -En 's#(\s|^)trksmnkncd_notification_issue=([0-9]+)(\s|$)#\2#p') fi if [[ -v $issue_from_pr_body ]] && [[ -n $issue_from_pr_body ]] ; then From 4cef939cdb270b3f1404c26f492db354336bb67c Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 16 Apr 2025 11:43:47 -0400 Subject: [PATCH 4/4] dataconnect.yml: fix `[[ -v $issue_from_pr_body ]]` to `[[ -v issue_from_pr_body ]]` (remove the `$`) --- .github/workflows/dataconnect.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index c79338992a6..b7648526a79 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -289,7 +289,7 @@ jobs: issue_from_pr_body=$(gh issue view "$pr_number" --json body --jq '.body' -R ${{ github.repository }} | sed -En 's#(\s|^)trksmnkncd_notification_issue=([0-9]+)(\s|$)#\2#p') fi - if [[ -v $issue_from_pr_body ]] && [[ -n $issue_from_pr_body ]] ; then + if [[ -v issue_from_pr_body ]] && [[ -n $issue_from_pr_body ]] ; then issue="$issue_from_pr_body" elif [[ '${{ github.event_name }}' == 'schedule' ]] ; then # See https://github.com/firebase/firebase-android-sdk/issues/6857