-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
84 lines (66 loc) · 3.38 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
# This is a basic workflow to help you get started with Actions
#--------------------------------------------------------------
# Github Action Workflow to Deploy Flask App to ElasticBeansStalk
#
# Version Date Info
# 1.0 24 Nov 2020 Initial Version
#
# Made by Ashish Pratap Singh a Python Developer at WSS Copyright (c) 2020
#--------------------------------------------------------------
name: CI-CD-Pipeline
env:
EB_PACKAGE_S3_BUCKET_NAME: "your-s3-bucket-name"
EB_APPLICATION_NAME : "my_application_name" # your elasticbeanstalk application name
EB_ENVIRONMENT_NAME : "MyApplicationName-env" # your elasticbeanstalk environment name
DEPLOY_PACKAGE_NAME : "XXXXXXXXX-${{ github.sha }}.zip" # zip file name that will store in s3 bucket with unique value
AWS_REGION_NAME : "ap-south-1" # your application region
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- main
pull_request:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
connectinapp_ci_pipeline:
runs-on: ubuntu-latest
steps:
- name : Git clone our repository
uses : actions/checkout@v1
- name : Create ZIP deployment package
run : zip -r ${{ env.DEPLOY_PACKAGE_NAME }} ./ -x *.git*
- name : Configure my AWS Credentials
uses : aws-actions/configure-aws-credentials@v1
with :
aws-access-key-id : ${{ secrets.MY_AWS_ACCESS_KEY }} # created in IMA user in step 2
aws-secret-access-key : ${{ secrets.MY_AWS_SECRET_KEY }} # created in IMA user in step 2
aws-region : ${{ env.AWS_REGION_NAME }}
- name: Copy our Deployment packages to s3 bucket
run : aws s3 cp ${{ env.DEPLOY_PACKAGE_NAME }} s3://${{ env.EB_PACKAGE_S3_BUCKET_NAME }}/
- name : Print nice message on complete of CI Pipeline
run : echo "CI Pipeline part finished successfully"
connectinapp_cd_pipeline:
runs-on: ubuntu-latest
needs : [connectinapp_ci_pipeline]
steps:
- name : Configure my AWS Credentials
uses : aws-actions/configure-aws-credentials@v1
with :
aws-access-key-id : ${{ secrets.MY_AWS_ACCESS_KEY }} # created in IMA user in step 2
aws-secret-access-key : ${{ secrets.MY_AWS_SECRET_KEY }} # created in IMA user in step 2
aws-region : ${{ env.AWS_REGION_NAME }}
- name : Create new ElasticBean Application Version
run : |
aws elasticbeanstalk create-application-version \
--application-name ${{ env.EB_APPLICATION_NAME }} \
--source-bundle S3Bucket="${{ env.EB_PACKAGE_S3_BUCKET_NAME }}",S3Key="${{ env.DEPLOY_PACKAGE_NAME }}" \
--version-label "Ver-${{ github.sha }}" \
--description "CommitSHA-${{ github.sha }}"
- name : Deploy our new Application Version
run : aws elasticbeanstalk update-environment --environment-name ${{ env.EB_ENVIRONMENT_NAME }} --version-label "Ver-${{ github.sha }}"
- name : Print nice message on complete of CD Pipeline
run : echo "CD Pipeline part finished successfully"
### .github/workflow/main.yml