-
Notifications
You must be signed in to change notification settings - Fork 6
173 lines (173 loc) · 6.73 KB
/
github-release-build-and-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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Chipmunk Deployment
on:
release:
types: [published]
jobs:
build-release-image:
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: AWS credentials configuration
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Amazon ECR login
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: agr_chipmunk
run: |
docker build --build-arg OVERWRITE_VERSION=${{ github.event.release.tag_name }} -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.event.release.tag_name }} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.event.release.tag_name }}
build-deploy-maven-central-package:
needs: [build-release-image]
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- run: cp src/main/resources/application.properties.defaults src/main/resources/application.properties
- name: Set Proper version
run: mvn versions:set -ntp -DnewVersion=${{ github.event.release.tag_name }}
- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Publish package
run: mvn --batch-mode -ntp deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
generate-deployment-package:
needs: [build-release-image]
runs-on: ubuntu-20.04
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Save chipmunk app version to be deployed in EB env variables through config file
run: |
cat .ebextensions/version.config
sed -i.bak "s/0.0.0/${{ github.event.release.tag_name }}/g" .ebextensions/version.config
cat .ebextensions/version.config
- name: Generate deployment package
run: zip -r ${{ github.event.release.tag_name }}.zip docker-compose.yml .ebextensions/
- name: Store deployment package in cache
uses: actions/cache@v2
with:
path: ${{ github.event.release.tag_name }}.zip
key: ${{github.workflow}}.${{github.run_id}}.${{github.run_number}}.${{github.run_attempt}}-eb-deployment-zip
deploy-to-production:
if: github.event.release.prerelease == false
needs: [generate-deployment-package]
runs-on: ubuntu-20.04
steps:
- name: Slack Notification
uses: tokorom/action-slack-incoming-webhook@main
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
text: "Auto Deployment to chipmunk production initiated"
- name: Fetch deployment package from cache
uses: actions/cache@v2
with:
path: ${{ github.event.release.tag_name }}.zip
key: ${{github.workflow}}.${{github.run_id}}.${{github.run_number}}.${{github.run_attempt}}-eb-deployment-zip
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v14
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: chipmunk-app
environment_name: chipmunk-production
version_label: ${{ github.event.release.tag_name }}
deployment_package: ${{ github.event.release.tag_name }}.zip
use_existing_version_if_available: true
region: us-east-1
- name: Slack Notification
uses: tokorom/action-slack-incoming-webhook@main
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
text: "Deployment of release ${{ github.event.release.tag_name }} to chipmunk production completed! :tada:"
attachments: |
[
{
"color": "good",
"author_name": "${{ github.actor }}",
"author_icon": "${{ github.event.sender.avatar_url }}",
"fields": [
{
"title": "Commit Message",
"value": "${{ env.COMMIT_MESSAGE }}"
},
{
"title": "Deployment URL",
"value": "https://fms.alliancegenome.org/swagger-ui/index.html"
}
]
}
]
deploy-to-dev:
if: github.event.release.prerelease == true
needs: [generate-deployment-package]
runs-on: ubuntu-20.04
steps:
- name: Slack Notification
uses: tokorom/action-slack-incoming-webhook@main
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
text: "Auto Deployment to chipmunk dev initiated"
- name: Fetch deployment package from cache
uses: actions/cache@v2
with:
path: ${{ github.event.release.tag_name }}.zip
key: ${{github.workflow}}.${{github.run_id}}.${{github.run_number}}.${{github.run_attempt}}-eb-deployment-zip
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v14
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: chipmunk-app
environment_name: chipmunk-dev
version_label: ${{ github.event.release.tag_name }}
deployment_package: ${{ github.event.release.tag_name }}.zip
use_existing_version_if_available: true
region: us-east-1
- name: Slack Notification
uses: tokorom/action-slack-incoming-webhook@main
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
text: "Deployment of release ${{ github.event.release.tag_name }} to chipmunk dev completed! :tada:"
attachments: |
[
{
"color": "good",
"author_name": "${{ github.actor }}",
"author_icon": "${{ github.event.sender.avatar_url }}",
"fields": [
{
"title": "Commit Message",
"value": "${{ env.COMMIT_MESSAGE }}"
},
{
"title": "Deployment URL",
"value": "https://fms-dev.alliancegenome.org/swagger-ui/index.html"
}
]
}
]