Skip to content

Commit a551d6d

Browse files
feat: Add GitHub Actions workflow for deploying services to Elastic Beanstalk
1 parent 2181d66 commit a551d6d

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/deploy.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Deploy to Elastic Beanstalk
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
env:
10+
AWS_REGION: us-east-1
11+
S3_BUCKET: elasticbeanstalk-us-east-1-036027635110
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- service: control-broker
21+
path: control_broker
22+
application: "controll server"
23+
environment: "Controllserver-env"
24+
- service: stream-cleaner
25+
path: stream_cleaner
26+
application: "Stream-cleaner"
27+
environment: "Stream-cleaner-env"
28+
- service: visual-controller
29+
path: visual_controller
30+
application: "visual-controller"
31+
environment: "Visual-controller-env"
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Configure AWS credentials
37+
uses: aws-actions/configure-aws-credentials@v4
38+
with:
39+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
40+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
41+
aws-region: ${{ env.AWS_REGION }}
42+
43+
- name: Compute package suffix
44+
id: suffix
45+
shell: bash
46+
run: |
47+
SHORT_SHA="${GITHUB_SHA::7}"
48+
TIMESTAMP="$(date +%Y%m%d%H%M%S)"
49+
echo "value=${SHORT_SHA}-${TIMESTAMP}" >> "$GITHUB_OUTPUT"
50+
51+
- name: Package service
52+
id: package
53+
working-directory: ${{ matrix.path }}
54+
shell: bash
55+
run: |
56+
ZIP_NAME="${{ matrix.service }}-${{ steps.suffix.outputs.value }}.zip"
57+
zip -r "../${ZIP_NAME}" .
58+
echo "zip-name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
59+
60+
- name: Upload package to S3
61+
id: upload
62+
env:
63+
ZIP_NAME: ${{ steps.package.outputs.zip-name }}
64+
shell: bash
65+
run: |
66+
S3_KEY="deployments/${{ matrix.service }}/${ZIP_NAME}"
67+
aws s3 cp "${ZIP_NAME}" "s3://${{ env.S3_BUCKET }}/${S3_KEY}"
68+
echo "s3-key=${S3_KEY}" >> "$GITHUB_OUTPUT"
69+
70+
- name: Create Elastic Beanstalk application version
71+
id: version
72+
env:
73+
VERSION_LABEL: ${{ matrix.service }}-${{ steps.suffix.outputs.value }}
74+
shell: bash
75+
run: |
76+
aws elasticbeanstalk create-application-version \
77+
--application-name "${{ matrix.application }}" \
78+
--version-label "${VERSION_LABEL}" \
79+
--source-bundle S3Bucket=${{ env.S3_BUCKET }},S3Key=${{ steps.upload.outputs.s3-key }} \
80+
--process
81+
echo "version-label=${VERSION_LABEL}" >> "$GITHUB_OUTPUT"
82+
83+
- name: Update Elastic Beanstalk environment
84+
shell: bash
85+
run: |
86+
aws elasticbeanstalk update-environment \
87+
--environment-name "${{ matrix.environment }}" \
88+
--version-label "${{ steps.version.outputs.version-label }}"

0 commit comments

Comments
 (0)