Skip to content

Commit 65c3518

Browse files
authored
update prod pipeline (#3)
1 parent cd4d136 commit 65c3518

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Deploy Kainoscore to Prod
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to deploy to prod (e.g. 1.10.1)'
8+
required: true
9+
10+
env:
11+
AWS_REGION: eu-west-2
12+
DEPLOYMENT_ROLE: arn:aws:iam::696793786584:role/GHA-CodeBuild-Service-Role
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
ENVIRONMENT: prod
15+
16+
permissions:
17+
id-token: write
18+
contents: write
19+
20+
jobs:
21+
deploy:
22+
name: Deploy to Prod
23+
runs-on: ubuntu-latest
24+
environment: Prod
25+
outputs:
26+
version: ${{ github.event.inputs.version }}
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Configure AWS credentials via OIDC
33+
uses: aws-actions/[email protected]
34+
with:
35+
role-to-assume: ${{ env.DEPLOYMENT_ROLE }}
36+
aws-region: ${{ env.AWS_REGION }}
37+
38+
- name: Install Required Tools
39+
run: |
40+
npm install -g typescript
41+
echo "NODE.JS version: $(node -v)"
42+
echo "NPM version: $(npm -v)"
43+
echo "AWS CLI version: $(aws --version)"
44+
45+
- name: Prepare Scripts
46+
run: |
47+
# Make sure the script file exists before making it executable
48+
if [ ! -f "./pipeline_scripts/deploy-to-prod.sh" ]; then
49+
echo "ERROR: deploy-to-prod.sh not found in pipeline_scripts directory"
50+
ls -la ./pipeline_scripts/
51+
exit 1
52+
fi
53+
54+
chmod +x ./pipeline_scripts/deploy-to-prod.sh
55+
chmod +x ./pipeline_scripts/update-lambda-functions.sh
56+
chmod +x ./pipeline_scripts/functions.sh
57+
chmod +x ./pipeline_scripts/deploy-static-files-prod.sh
58+
ls -la ./pipeline_scripts/
59+
60+
- name: Copy Artifacts and Deploy to Prod
61+
run: |
62+
echo "Starting prod deployment for version ${{ github.event.inputs.version }}"
63+
./pipeline_scripts/deploy-to-prod.sh "${{ github.event.inputs.version }}"
64+
./pipeline_scripts/deploy-static-files-prod.sh "${{ github.event.inputs.version }}"
65+
66+
- name: Deployment Summary
67+
run: |
68+
echo "✅ Successfully deployed version v${{ github.event.inputs.version }} to prod"
69+
echo " • Deployment Time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
70+
echo " • Deployed by: ${{ github.actor }}"
71+
72+
# Create an artifact with deployment details for tracking
73+
mkdir -p deployment-info
74+
cat > deployment-info/prod-deployment.txt << EOF
75+
Version: v${{ github.event.inputs.version }}
76+
Time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
77+
Actor: ${{ github.actor }}
78+
Workflow Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
79+
EOF
80+
81+
- name: Upload Deployment Info
82+
uses: actions/[email protected]
83+
with:
84+
name: prod-deployment-v${{ github.event.inputs.version }}-${{ github.run_id }}
85+
path: deployment-info
86+
retention-days: 90
87+
88+
create-release:
89+
name: Create GitHub Release
90+
runs-on: ubuntu-latest
91+
needs: deploy
92+
permissions:
93+
contents: write
94+
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
101+
- name: Generate release notes
102+
id: release-notes
103+
run: |
104+
echo "Generating release notes for v${{ needs.deploy.outputs.version }}"
105+
106+
# Extract commits since last release
107+
git fetch --tags
108+
PREV_TAG=$(git describe --tags --abbrev=0 --match "v*" 2>/dev/null || echo "none")
109+
110+
if [ "$PREV_TAG" == "none" ]; then
111+
COMMITS=$(git log --pretty=format:"- %s (%h)" -10)
112+
else
113+
COMMITS=$(git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD)
114+
fi
115+
116+
# Create release notes file
117+
cat > release-notes.md << EOF
118+
# Release v${{ needs.deploy.outputs.version }}
119+
120+
## What's Changed
121+
${COMMITS}
122+
123+
## Deployment Information
124+
- Deployed to: Prod
125+
- Deployment time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
126+
- Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
127+
EOF
128+
129+
cat release-notes.md
130+
131+
- name: Create GitHub Release
132+
uses: softprops/[email protected]
133+
with:
134+
name: "v${{ needs.deploy.outputs.version }} (Prod)"
135+
tag_name: "v${{ needs.deploy.outputs.version }}"
136+
body_path: release-notes.md
137+
draft: false
138+
prerelease: true
139+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)