Skip to content

Commit d829c7d

Browse files
refactor: Update deploy workflow to streamline service deployment and add media relay support
1 parent 98d6cf7 commit d829c7d

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

.github/workflows/deploy.yaml

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: Deploy Infrastructure and Services
22

33
on:
4+
push:
5+
branches:
6+
- main
47
workflow_dispatch:
58

69
env:
710
AWS_REGION: us-east-1
811
S3_BUCKET: elasticbeanstalk-us-east-1-036027635110
912

1013
jobs:
11-
deploy:
14+
deploy_services:
15+
if: github.event_name == 'push'
1216
runs-on: ubuntu-latest
1317
strategy:
1418
fail-fast: false
@@ -18,20 +22,14 @@ jobs:
1822
path: control_broker
1923
application: "controll server"
2024
environment: "Controllserver-env"
21-
deployer: elasticbeanstalk
2225
- service: stream-cleaner
2326
path: stream_cleaner
2427
application: "Stream-cleaner"
2528
environment: "Stream-cleaner-env"
26-
deployer: elasticbeanstalk
2729
- service: visual-controller
2830
path: visual_controller
2931
application: "visual-controller"
3032
environment: "Visual-controller-env"
31-
deployer: elasticbeanstalk
32-
- service: media-relay
33-
path: infra/terraform/media_relay
34-
deployer: terraform
3533
steps:
3634
- name: Checkout repository
3735
uses: actions/checkout@v4
@@ -49,12 +47,6 @@ jobs:
4947
env:
5048
AWS_SHARED_CREDENTIALS_FILE: ~/.aws/credentials
5149

52-
- name: Set up Terraform
53-
if: ${{ matrix.deployer == 'terraform' }}
54-
uses: hashicorp/setup-terraform@v3
55-
with:
56-
terraform_version: 1.7.5
57-
5850
- name: Build visual controller frontend
5951
if: ${{ matrix.service == 'visual-controller' }}
6052
shell: bash
@@ -73,7 +65,6 @@ jobs:
7365
id: package
7466
working-directory: ${{ matrix.path }}
7567
shell: bash
76-
if: ${{ matrix.deployer == 'elasticbeanstalk' }}
7768
run: |
7869
ZIP_NAME="${{ matrix.service }}-${{ steps.suffix.outputs.value }}.zip"
7970
shopt -s dotglob
@@ -85,7 +76,6 @@ jobs:
8576
env:
8677
ZIP_NAME: ${{ steps.package.outputs.zip-name }}
8778
shell: bash
88-
if: ${{ matrix.deployer == 'elasticbeanstalk' }}
8979
run: |
9080
S3_KEY="deployments/${{ matrix.service }}/${ZIP_NAME}"
9181
aws s3 cp "${ZIP_NAME}" "s3://${{ env.S3_BUCKET }}/${S3_KEY}"
@@ -96,7 +86,6 @@ jobs:
9686
env:
9787
VERSION_LABEL: ${{ matrix.service }}-${{ steps.suffix.outputs.value }}
9888
shell: bash
99-
if: ${{ matrix.deployer == 'elasticbeanstalk' }}
10089
run: |
10190
aws elasticbeanstalk create-application-version \
10291
--application-name "${{ matrix.application }}" \
@@ -107,15 +96,40 @@ jobs:
10796
10897
- name: Update Elastic Beanstalk environment
10998
shell: bash
110-
if: ${{ matrix.deployer == 'elasticbeanstalk' }}
11199
run: |
112100
aws elasticbeanstalk update-environment \
113101
--environment-name "${{ matrix.environment }}" \
114102
--version-label "${{ steps.version.outputs.version-label }}"
115103
104+
deploy_media_relay:
105+
if: github.event_name == 'workflow_dispatch'
106+
runs-on: ubuntu-latest
107+
env:
108+
SERVICE_PATH: infra/terraform/media_relay
109+
steps:
110+
- name: Checkout repository
111+
uses: actions/checkout@v4
112+
113+
- name: Create AWS credentials file
114+
shell: bash
115+
run: |
116+
mkdir -p ~/.aws
117+
echo "${{ secrets.AWS_CREDENTIALS_B64 }}" | base64 -d > ~/.aws/credentials
118+
119+
- name: Configure AWS credentials
120+
uses: aws-actions/configure-aws-credentials@v4
121+
with:
122+
aws-region: ${{ env.AWS_REGION }}
123+
env:
124+
AWS_SHARED_CREDENTIALS_FILE: ~/.aws/credentials
125+
126+
- name: Set up Terraform
127+
uses: hashicorp/setup-terraform@v3
128+
with:
129+
terraform_version: 1.7.5
130+
116131
- name: Write terraform.tfvars from secret
117-
if: ${{ matrix.deployer == 'terraform' }}
118-
working-directory: ${{ matrix.path }}
132+
working-directory: ${{ env.SERVICE_PATH }}
119133
env:
120134
TFVARS_B64: ${{ secrets.MEDIA_RELAY_TFVARS_B64 }}
121135
shell: bash
@@ -127,17 +141,15 @@ jobs:
127141
echo "$TFVARS_B64" | base64 -d > terraform.tfvars
128142
129143
- name: Terraform init
130-
if: ${{ matrix.deployer == 'terraform' }}
131-
working-directory: ${{ matrix.path }}
144+
working-directory: ${{ env.SERVICE_PATH }}
132145
shell: bash
133146
env:
134147
TF_IN_AUTOMATION: 1
135148
run: |
136149
terraform init -input=false
137150
138151
- name: Terraform destroy existing instance
139-
if: ${{ matrix.deployer == 'terraform' }}
140-
working-directory: ${{ matrix.path }}
152+
working-directory: ${{ env.SERVICE_PATH }}
141153
shell: bash
142154
env:
143155
TF_IN_AUTOMATION: 1
@@ -146,11 +158,9 @@ jobs:
146158
terraform destroy -input=false -auto-approve -target=aws_eip_association.mediamtx || true
147159
148160
- name: Terraform apply
149-
if: ${{ matrix.deployer == 'terraform' }}
150-
working-directory: ${{ matrix.path }}
161+
working-directory: ${{ env.SERVICE_PATH }}
151162
shell: bash
152163
env:
153164
TF_IN_AUTOMATION: 1
154165
run: |
155166
terraform apply -input=false -auto-approve
156-

0 commit comments

Comments
 (0)