diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index f5a58ef6896..b7648526a79 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 @@ -267,19 +268,55 @@ 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) + 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' -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 + issue="$issue_from_pr_body" + elif [[ '${{ github.event_name }}' == 'schedule' ]] ; then + # See https://github.com/firebase/firebase-android-sdk/issues/6857 + issue=6857 + else + 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 <