Skip to content

Commit f746ee9

Browse files
committed
dataconnect_demo_app.yml: factor out notification sending into .github/actions/dataconnect-send-notifications/action.yml
1 parent 8177f76 commit f746ee9

File tree

2 files changed

+92
-58
lines changed

2 files changed

+92
-58
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Data Connect Workflow Notifications
2+
description: Notify a GitHub Issue with the results of a workflow.
3+
4+
inputs:
5+
python-version:
6+
required: true
7+
default: "3.13"
8+
github-issue-for-scheduled-runs:
9+
required: true
10+
job-results-file:
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
show-progress: false
19+
sparse-checkout: 'firebase-dataconnect/ci/'
20+
21+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
22+
with:
23+
python-version: ${{ inputs.python-version }}
24+
25+
- run: pip install -r requirements.txt
26+
working-directory: firebase-dataconnect/ci
27+
28+
- id: issue-id
29+
name: Determine GitHub Issue For Commenting
30+
working-directory: firebase-dataconnect/ci
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
args=(
35+
python
36+
calculate_github_issue_for_commenting.py
37+
--issue-output-file=github_issue_number.txt
38+
--pr-output-file=github_pr_number.txt
39+
--github-repository='${{ github.repository }}'
40+
--github-ref='${{ github.ref }}'
41+
--github-event-name='${{ github.event_name }}'
42+
--pr-body-github-issue-key=trksmnkncd_notification_issue
43+
--github-issue-for-scheduled-run='${{ inputs.github-issue-for-scheduled-runs }}'
44+
)
45+
echo "${args[*]}"
46+
"${args[@]}"
47+
48+
set -xv
49+
issue="$(cat github_issue_number.txt)"
50+
echo "issue=$issue" >> "$GITHUB_OUTPUT"
51+
pr="$(cat github_pr_number.txt)"
52+
echo "pr=$pr" >> "$GITHUB_OUTPUT"
53+
54+
- name: Post Comment on GitHub Issue
55+
if: steps.issue-id.outputs.issue != ''
56+
working-directory: firebase-dataconnect/ci
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
args=(
61+
python
62+
post_comment_for_job_results.py
63+
--github-issue='${{ steps.issue-id.outputs.issue }}'
64+
--github-workflow='${{ github.workflow }}'
65+
--github-repository='${{ github.repository }}'
66+
--github-sha='${{ github.sha }}'
67+
--github-repository-html-url='${{ github.event.repository.html_url }}'
68+
--github-run-id='${{ github.run_id }}'
69+
--github-run-number='${{ github.run_number }}'
70+
--github-run-attempt='${{ github.run_attempt }}'
71+
--triggering-pr='${{ steps.issue-id.outputs.pr }}'
72+
)
73+
74+
while read -r line; do
75+
args=("${args[@]}" "$line")
76+
done <'${{ inputs.job-results-file }}'
77+
78+
echo "${args[*]}"
79+
exec "${args[@]}"

.github/workflows/dataconnect_demo_app.yml

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -179,64 +179,19 @@ jobs:
179179
issues: write
180180
runs-on: ubuntu-latest
181181
steps:
182-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
183-
with:
184-
show-progress: false
185-
sparse-checkout: 'firebase-dataconnect/ci/'
182+
- name: Create Job Results File
183+
id: create-job-results-file
184+
run: |
185+
set -xveuo pipefail
186+
job_results_file="$(mktemp)"
186187
187-
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
188-
with:
189-
python-version: ${{ env.FDC_PYTHON_VERSION }}
188+
echo 'test:${{ needs.test.result }}' >>"$job_results_file"
189+
echo 'spotlessCheck:${{ needs.spotlessCheck.result }}' >>"$job_results_file"
190190
191-
- run: pip install -r requirements.txt
192-
working-directory: firebase-dataconnect/ci
191+
echo "job_results_file=$job_results_file" >>"$GITHUB_OUTPUT"
193192
194-
- id: issue-id
195-
name: Determine GitHub Issue For Commenting
196-
working-directory: firebase-dataconnect/ci
197-
env:
198-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199-
run: |
200-
args=(
201-
python
202-
calculate_github_issue_for_commenting.py
203-
--issue-output-file=github_issue_number.txt
204-
--pr-output-file=github_pr_number.txt
205-
--github-repository='${{ github.repository }}'
206-
--github-ref='${{ github.ref }}'
207-
--github-event-name='${{ github.event_name }}'
208-
--pr-body-github-issue-key=trksmnkncd_notification_issue
209-
--github-issue-for-scheduled-run=6891 # https://github.com/firebase/firebase-android-sdk/issues/6891
210-
)
211-
echo "${args[*]}"
212-
"${args[@]}"
213-
214-
set -xv
215-
issue="$(cat github_issue_number.txt)"
216-
echo "issue=$issue" >> "$GITHUB_OUTPUT"
217-
pr="$(cat github_pr_number.txt)"
218-
echo "pr=$pr" >> "$GITHUB_OUTPUT"
219-
220-
- name: Post Comment on GitHub Issue
221-
if: steps.issue-id.outputs.issue != ''
222-
working-directory: firebase-dataconnect/ci
223-
env:
224-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225-
run: |
226-
args=(
227-
python
228-
post_comment_for_job_results.py
229-
--github-issue='${{ steps.issue-id.outputs.issue }}'
230-
--github-workflow='${{ github.workflow }}'
231-
--github-repository='${{ github.repository }}'
232-
--github-sha='${{ github.sha }}'
233-
--github-repository-html-url='${{ github.event.repository.html_url }}'
234-
--github-run-id='${{ github.run_id }}'
235-
--github-run-number='${{ github.run_number }}'
236-
--github-run-attempt='${{ github.run_attempt }}'
237-
--triggering-pr='${{ steps.issue-id.outputs.pr }}'
238-
'test:${{ needs.test.result }}'
239-
'spotlessCheck:${{ needs.spotlessCheck.result }}'
240-
)
241-
echo "${args[*]}"
242-
exec "${args[@]}"
193+
- uses: ./.github/actions/dataconnect-send-notifications
194+
with:
195+
python-version: ${{ env.FDC_PYTHON_VERSION }}
196+
github-issue-for-scheduled-runs: "6891"
197+
job-results-file: ${{ steps.create-job-results-file.outputs.job_results_file }}

0 commit comments

Comments
 (0)