-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (54 loc) · 2.29 KB
/
hamlet_deploy.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
# From https://dev.to/vlntsolo/django-full-ci-cd-flow-to-aws-with-github-actions-and-s3-2enp#1-aws-beanstalk-environment
name: CI-CD pipeline to AWS
env:
EB_S3_BUCKET_NAME: "elasticbeanstalk-us-east-2-214921548711"
EB_APPLICATION_NAME: "hamlet-env-2021-small"
EB_ENVIRONMENT_NAME: "Hamletenv2021small-env"
DEPLOY_PACKAGE_NAME: "django-app-${{ github.sha }}.zip"
AWS_REGION_NAME: "us-east-2"
on:
push:
branches:
- master #Use your own branch here (Might be staging or testing)
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: [3.8.10]
steps:
- name: Git clone on our repo
uses: actions/checkout@v3
- name: Create zip deployment package
run: zip -r ${{ env.DEPLOY_PACKAGE_NAME }} ./ -x *.git*
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-region: ${{ env.AWS_REGION_NAME }}
- name: Copying file to S3
run: aws s3 cp ${{ env.DEPLOY_PACKAGE_NAME }} s3://${{ env.EB_S3_BUCKET_NAME }}/
- name: Print nice message on success finish
run: echo "CI part finished successfuly"
deploy:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-region: ${{ env.AWS_REGION_NAME }}
- name: Create new EBL app ver
run: |
aws elasticbeanstalk create-application-version \
--application-name ${{ env.EB_APPLICATION_NAME }} \
--source-bundle S3Bucket="${{ env.EB_S3_BUCKET_NAME }}",S3Key="${{ env.DEPLOY_PACKAGE_NAME }}" \
--version-label "${{ github.sha }}"
- name: Deploy new app
run: aws elasticbeanstalk update-environment --environment-name ${{ env.EB_ENVIRONMENT_NAME }} --version-label "${{ github.sha }}"
- name: Print nice message on success finish
run: echo "CD part finished successfuly"
# 4) [steps] block lists names and actual commands to execute on the virtual machine.