Skip to content

Commit 72452df

Browse files
yurisasukeTyk Bot
authored andcommitted
addpr-id-that-caused-a deployment (#575)
Co-authored-by: itachi sasuke <8012032+Keithwachira@users.noreply.github.com> (cherry picked from commit 8cf8678)
1 parent 6db765a commit 72452df

File tree

2 files changed

+102
-5
lines changed

2 files changed

+102
-5
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ on:
88
required: false
99
default: ''
1010
type: string
11+
triggering_pr_number:
12+
description: 'PR number that triggered this deployment'
13+
required: false
14+
default: ''
15+
type: string
16+
triggering_pr_title:
17+
description: 'PR title that triggered this deployment'
18+
required: false
19+
default: ''
20+
type: string
21+
triggering_commit_sha:
22+
description: 'Commit SHA that triggered this deployment'
23+
required: false
24+
default: ''
25+
type: string
26+
triggering_branch:
27+
description: 'Branch that triggered this deployment'
28+
required: false
29+
default: ''
30+
type: string
1131

1232
# Ensure only latest deployment runs
1333
concurrency:
@@ -19,6 +39,17 @@ jobs:
1939
runs-on: ubuntu-latest
2040

2141
steps:
42+
- name: Log deployment trigger information
43+
run: |
44+
echo "🚀 Starting documentation deployment"
45+
echo "📋 Trigger Information:"
46+
echo " - Branch: ${{ inputs.triggering_branch || 'N/A' }}"
47+
echo " - Commit: ${{ inputs.triggering_commit_sha || 'N/A' }}"
48+
echo " - PR: ${{ inputs.triggering_pr_number && format('#{0} - {1}', inputs.triggering_pr_number, inputs.triggering_pr_title) || 'N/A (direct push)' }}"
49+
echo " - Timestamp: $(date)"
50+
echo " - Workflow Run: ${{ github.run_id }}"
51+
echo " - Subfolder: ${{ inputs.subfolder || '(root deployment)' }}"
52+
2253
- name: Checkout production branch
2354
uses: actions/checkout@v4
2455
with:
@@ -287,10 +318,16 @@ jobs:
287318
288319
This PR contains automatically merged documentation from multiple branches.
289320
290-
**Generated from:** `branches-config.json`
291-
**Timestamp:** ${{ github.event.head_commit.timestamp }}
292-
**Run ID:** ${{ github.run_id }}
293-
**Subfolder:** `${{ inputs.subfolder || '(root deployment)' }}`
321+
**Triggered by:**
322+
- **Branch:** ${{ inputs.triggering_branch || 'N/A' }}
323+
- **Commit:** ${{ inputs.triggering_commit_sha || 'N/A' }}
324+
- **PR:** ${{ inputs.triggering_pr_number && format('#{0} - {1}', inputs.triggering_pr_number, inputs.triggering_pr_title) || 'N/A (direct push)' }}
325+
326+
**Deployment Details:**
327+
- **Generated from:** `branches-config.json`
328+
- **Run ID:** ${{ github.run_id }}
329+
- **Subfolder:** `${{ inputs.subfolder || '(root deployment)' }}`
330+
- **Timestamp:** $(date)
294331
295332
### Changes Include:
296333
- ✅ Merged documentation from multiple branches
@@ -337,6 +374,11 @@ jobs:
337374
run: |
338375
echo "## 📚 Documentation Deployment Summary" >> $GITHUB_STEP_SUMMARY
339376
echo "" >> $GITHUB_STEP_SUMMARY
377+
echo "### 🚀 Trigger Information" >> $GITHUB_STEP_SUMMARY
378+
echo "- **Branch:** ${{ inputs.triggering_branch || 'N/A' }}" >> $GITHUB_STEP_SUMMARY
379+
echo "- **Commit:** ${{ inputs.triggering_commit_sha || 'N/A' }}" >> $GITHUB_STEP_SUMMARY
380+
echo "- **PR:** ${{ inputs.triggering_pr_number && format('#{0} - {1}', inputs.triggering_pr_number, inputs.triggering_pr_title) || 'N/A (direct push)' }}" >> $GITHUB_STEP_SUMMARY
381+
echo "" >> $GITHUB_STEP_SUMMARY
340382
echo "### ✅ Successfully merged documentation" >> $GITHUB_STEP_SUMMARY
341383
echo "" >> $GITHUB_STEP_SUMMARY
342384
echo "**Generated files:**" >> $GITHUB_STEP_SUMMARY

.github/workflows/trigger-docs-deploy.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,65 @@ jobs:
1010
trigger-deploy:
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Extract PR information from commit
14+
id: get-pr
15+
run: |
16+
COMMIT_MESSAGE="${{ github.event.head_commit.message }}"
17+
echo "Commit message: $COMMIT_MESSAGE"
18+
19+
# Try to extract PR number from commit message
20+
PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oE '#[0-9]+' | head -1 | sed 's/#//')
21+
22+
if [ -n "$PR_NUMBER" ]; then
23+
echo "Found PR number: #$PR_NUMBER"
24+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
25+
echo "has_pr=true" >> $GITHUB_OUTPUT
26+
27+
# Extract PR title (everything before the PR number reference)
28+
PR_TITLE=$(echo "$COMMIT_MESSAGE" | sed 's/ (#[0-9]\+).*//' | head -1)
29+
echo "pr_title=$PR_TITLE" >> $GITHUB_OUTPUT
30+
else
31+
echo "No PR number found in commit message (direct push)"
32+
echo "has_pr=false" >> $GITHUB_OUTPUT
33+
fi
34+
1335
- name: Trigger production deployment
1436
run: |
37+
# Prepare the dispatch payload
38+
if [ "${{ steps.get-pr.outputs.has_pr }}" = "true" ]; then
39+
PAYLOAD=$(jq -n \
40+
--arg ref "production" \
41+
--arg pr_number "${{ steps.get-pr.outputs.pr_number }}" \
42+
--arg pr_title "${{ steps.get-pr.outputs.pr_title }}" \
43+
--arg commit_sha "${{ github.sha }}" \
44+
--arg branch "${{ github.ref_name }}" \
45+
'{
46+
ref: $ref,
47+
inputs: {
48+
triggering_pr_number: $pr_number,
49+
triggering_pr_title: $pr_title,
50+
triggering_commit_sha: $commit_sha,
51+
triggering_branch: $branch
52+
}
53+
}')
54+
echo "Triggering deployment with PR #${{ steps.get-pr.outputs.pr_number }}"
55+
else
56+
PAYLOAD=$(jq -n \
57+
--arg ref "production" \
58+
--arg commit_sha "${{ github.sha }}" \
59+
--arg branch "${{ github.ref_name }}" \
60+
'{
61+
ref: $ref,
62+
inputs: {
63+
triggering_commit_sha: $commit_sha,
64+
triggering_branch: $branch
65+
}
66+
}')
67+
echo "Triggering deployment (direct push, no PR)"
68+
fi
69+
1570
curl -X POST \
1671
-H "Authorization: token ${{ secrets.ORG_GH_TOKEN }}" \
1772
-H "Accept: application/vnd.github.v3+json" \
1873
https://api.github.com/repos/${{ github.repository }}/actions/workflows/deploy-docs.yml/dispatches \
19-
-d '{"ref": "production"}'
74+
-d "$PAYLOAD"

0 commit comments

Comments
 (0)