-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) · 2.78 KB
/
parent-workflow.yml
File metadata and controls
88 lines (73 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Parent Workflow - Comprehensive CI/CD
on:
push:
branches: [main, develop]
permissions:
contents: read
pages: write
pull-requests: write
id-token: write
jobs:
# Run child workflows in parallel
run-tests:
name: "Execute Test Suite"
uses: ./.github/workflows/child-workflow-1.yml
with:
artifact_id: "child1-${{ github.ref_name }}-${{ github.sha }}"
run-build-security:
name: "Execute Build & Security Checks"
uses: ./.github/workflows/child-workflow-2.yml
with:
artifact_id: "child2-${{ github.ref_name }}-${{ github.sha }}"
# Parent workflow job that runs after both children complete
collect-and-deploy:
name: "Collect Results & Deploy"
needs: [run-tests, run-build-security]
runs-on: ubuntu-latest
if: always() # Run even if some child workflows fail
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check child workflow results
run: |
echo "=== Child Workflow Results ==="
echo "Tests workflow: ${{ needs.run-tests.result }}"
echo "Build & Security workflow: ${{ needs.run-build-security.result }}"
echo "================================"
# Fail if any required child workflow failed
if [[ "${{ needs.run-tests.result }}" != "success" ]] || \
[[ "${{ needs.run-build-security.result }}" != "success" ]]; then
echo "❌ One or more child workflows failed"
exit 1
fi
echo "✅ All child workflows completed successfully!"
- name: Download test artifacts from child workflow 1
uses: actions/download-artifact@v4.1.8
with:
name: "child1-${{ github.ref_name }}-${{ github.sha }}"
path: artifacts/
- name: Download build and security artifacts from child workflow 2
uses: actions/download-artifact@v4.1.8
with:
name: "child2-${{ github.ref_name }}-${{ github.sha }}"
path: artifacts/
- name: Create deployment package
run: |
echo "Creating deployment package..."
mkdir -p deployment
echo "Deployment ready - $(date)" > deployment/deployment-info.txt
# Copy all artifacts to deployment folder
if [ -d "artifacts" ]; then
cp -r artifacts/* deployment/
fi
- name: Upload final deployment artifacts
uses: actions/upload-artifact@v4
with:
name: "deployment-package-${{ github.ref_name }}-${{ github.sha }}"
path: deployment/
- name: Deployment simulation
run: |
echo "🚀 Simulating deployment..."
sleep 2
echo "✅ Deployment completed successfully!"
echo "🎉 Parent workflow execution finished!"