-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (61 loc) · 2.62 KB
/
deploy-prod.yml
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
name: Build, push and deploy Docker image
on:
push:
branches: [prod]
env:
AWS_REGION: ap-southeast-1 # set this to your preferred AWS region
EBS_APPLICATION_NAME: firecloud # set this to your EBS application name
EBS_ENVIRONMENT_NAME: Firecloud-env-1 # set this to your EBS environment name
ECR_REPOSITORY: firecloud-application-versions-prod # set this to your ECR repository name
ECR_REPOSITORY_URI: 892404399729.dkr.ecr.ap-southeast-1.amazonaws.com
S3_BUCKET_NAME: firecloud-application-versions-prod
defaults:
run:
working-directory: ./fire-cloud
jobs:
build-push-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:firecloud_${{github.run_number}} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:firecloud_${{github.run_number}}
- name: Replace image in docker compose file
env:
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
ECR_REPOSITORY_URI: ${{ env.ECR_REPOSITORY_URI }}
run: |
cp docker-compose.prod.yml docker-compose.yml
sed -i "s/<ECR_REGISTRY>/$ECR_REPOSITORY_URI/g" docker-compose.yml
sed -i "s/<SERVER_NAME>/$ECR_REPOSITORY/g" docker-compose.yml
sed -i "s/<TAG>/firecloud_${{github.run_number}}/g" docker-compose.yml
- name: Zip the docker compose file
run: |
zip deploy.zip docker-compose.yml
- name: Upload zip to S3
env:
S3_BUCKET_NAME: ${{ env.S3_BUCKET_NAME }}
run: |
aws s3 cp deploy.zip s3://$S3_BUCKET_NAME/firecloud_deploy_${{github.run_number}}.zip
rm deploy.zip
- name: Deploy to EBS
run: |
aws elasticbeanstalk create-application-version \
--application-name ${{ env.EBS_APPLICATION_NAME }} --version-label ${{github.run_number}} \
--source-bundle S3Bucket=${{ env.S3_BUCKET_NAME }},S3Key=firecloud_deploy_${{github.run_number}}.zip
aws elasticbeanstalk update-environment \
--environment-name ${{ env.EBS_ENVIRONMENT_NAME }} --version-label ${{github.run_number}}