@@ -17,6 +17,14 @@ inputs:
1717 slack_api_response :
1818 description : ' JSON response from Slack API containing message details'
1919 required : true
20+ slack_slugs :
21+ description : ' Slack slugs for CC'
22+ required : false
23+ default : ' <!subteam^S0555JBV36D> <!subteam^S03SW7DM8P3> <!subteam^S03SHJ20350>'
24+ custom_message :
25+ description : ' Custom message to post to the release thread'
26+ required : false
27+ default : ' '
2028
2129outputs :
2230 has_thread_info :
@@ -35,14 +43,6 @@ outputs:
3543runs :
3644 using : ' composite'
3745 steps :
38- - name : Download release info artifact
39- id : download-release-info
40- continue-on-error : true
41- uses : actions/download-artifact@v4
42- with :
43- name : release-info-v${{ inputs.monorepo_release_version }}-${{ inputs.release_ticket_id }}
44- path : release-info/
45-
4646 - name : Ensure jq is installed
4747 shell : bash
4848 run : |
6969 jq --version
7070 fi
7171
72+ - name : Download release info artifact from original workflow
73+ id : download-release-info
74+ continue-on-error : true
75+ shell : bash
76+ env :
77+ GITHUB_TOKEN : ${{ github.token }}
78+ REPO : ${{ github.repository }}
79+ ARTIFACT_NAME : release-info-v${{ inputs.monorepo_release_version }}-${{ inputs.release_ticket_id }}
80+ run : |
81+ # Create directory for artifact
82+ mkdir -p release-info
83+
84+ # Find the workflow run that created this artifact
85+ # Look for the draft-new-release workflow runs
86+ echo "Searching for artifact: $ARTIFACT_NAME"
87+
88+ # Get the workflow ID for draft-new-release
89+ workflow_response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
90+ "https://api.github.com/repos/$REPO/actions/workflows/draft-new-release.yml")
91+
92+ workflow_id=$(echo "$workflow_response" | jq -r '.id')
93+
94+ if [ "$workflow_id" = "null" ] || [ -z "$workflow_id" ]; then
95+ echo "Could not find draft-new-release workflow"
96+ echo "Response: $workflow_response"
97+ exit 1
98+ fi
99+
100+ echo "Found workflow ID: $workflow_id"
101+
102+ # Get recent workflow runs (last 50 runs, completed status)
103+ runs_response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
104+ "https://api.github.com/repos/$REPO/actions/workflows/$workflow_id/runs?per_page=50&status=completed")
105+
106+ if [ "$(echo "$runs_response" | jq -r '.total_count')" = "0" ]; then
107+ echo "No completed workflow runs found"
108+ exit 1
109+ fi
110+
111+ # Find the run that has our artifact
112+ artifact_found=false
113+ run_count=$(echo "$runs_response" | jq -r '.workflow_runs | length')
114+ echo "Checking $run_count workflow runs for artifact..."
115+
116+ for i in $(seq 0 $((run_count - 1))); do
117+ run_id=$(echo "$runs_response" | jq -r ".workflow_runs[$i].id")
118+ run_name=$(echo "$runs_response" | jq -r ".workflow_runs[$i].name")
119+ run_created=$(echo "$runs_response" | jq -r ".workflow_runs[$i].created_at")
120+
121+ echo "Checking run $run_id ($run_name) created at $run_created..."
122+
123+ artifacts_response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
124+ "https://api.github.com/repos/$REPO/actions/runs/$run_id/artifacts")
125+
126+ # Check if the response contains our artifact
127+ artifact_exists=$(echo "$artifacts_response" | jq -r ".artifacts[] | select(.name == \"$ARTIFACT_NAME\") | .name // empty")
128+
129+ if [ "$artifact_exists" = "$ARTIFACT_NAME" ]; then
130+ echo "Found artifact in run $run_id"
131+ artifact_id=$(echo "$artifacts_response" | jq -r ".artifacts[] | select(.name == \"$ARTIFACT_NAME\") | .id")
132+
133+ # Download the artifact
134+ download_response=$(curl -L -w "%{http_code}" -H "Authorization: token $GITHUB_TOKEN" \
135+ "https://api.github.com/repos/$REPO/actions/artifacts/$artifact_id/zip" \
136+ -o release-info.zip)
137+
138+ http_code="${download_response: -3}"
139+ if [ "$http_code" = "200" ]; then
140+ # Extract the artifact
141+ unzip -o release-info.zip -d release-info/
142+ rm release-info.zip
143+
144+ echo "Successfully downloaded and extracted artifact"
145+ artifact_found=true
146+ break
147+ else
148+ echo "Failed to download artifact, HTTP code: $http_code"
149+ fi
150+ fi
151+ done
152+
153+ if [ "$artifact_found" = false ]; then
154+ echo "Artifact $ARTIFACT_NAME not found in recent workflow runs"
155+ echo "This could mean:"
156+ echo "1. The artifact has expired (artifacts expire after 90 days)"
157+ echo "2. The artifact was never created"
158+ echo "3. The artifact name doesn't match"
159+
160+ exit 1
161+ fi
162+
72163 - name : Extract release info
73164 id : extract-info
74165 continue-on-error : true
@@ -141,13 +232,13 @@ runs:
141232 {
142233 "channel": "${{ steps.extract-info.outputs.channel_id }}",
143234 "thread_ts": "${{ steps.extract-info.outputs.thread_ts }}",
144- "text": ":white_check_mark: ${{ inputs.deployment_name }} deployment completed: <${{ steps.extract-message-url.outputs.message_url }}|View deployment details>\n\nCC: <!subteam^S0555JBV36D> <!subteam^S03SW7DM8P3> <!subteam^S03SHJ20350> ",
235+ "text": ":white_check_mark: ${{ inputs.deployment_name }} deployment completed: <${{ steps.extract-message-url.outputs.message_url }}|View deployment details>\n\nCC: ${{ inputs.slack_slugs }} ",
145236 "blocks": [
146237 {
147238 "type": "section",
148239 "text": {
149240 "type": "mrkdwn",
150- "text": ":white_check_mark: *${{ inputs.deployment_name }} deployment completed*\n <${{ steps.extract-message-url.outputs.message_url }}|View deployment details>\n\nCC: <!subteam^S0555JBV36D> <!subteam^S03SW7DM8P3> <!subteam^S03SHJ20350> "
241+ "text": ":white_check_mark: *${{ inputs.deployment_name }} deployment completed*${{ inputs.custom_message != '' && format('\n\n{0}', inputs.custom_message) }}\n <${{ steps.extract-message-url.outputs.message_url }}|View deployment details>\n\nCC: ${{ inputs.slack_slugs }} "
151242 }
152243 }
153244 ]
0 commit comments