-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (68 loc) · 2.58 KB
/
main-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
74
75
76
77
78
name: Prod Build and Deploy
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Builds artifact
build:
name: Build and Package
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: maven
- name: Build
run: |
echo "${{ secrets.GOOGLE_PLAY_KEY_PROD }}" > diagnosisview-api/src/main/resources/google-play-key.json
echo "${{ secrets.GOOGLE_PLAY_KEY_PROD }}" > diagnosisview-service/src/main/resources/google-play-key.json
mvn -B clean package -DskipTests=true -P production --file pom.xml
- name: Upload JAR
uses: actions/upload-artifact@v2
with:
#Set artifact name
name: diagnosisview-api-prod
#From this path
path: diagnosisview-api/target/diagnosisview-api-1.0-SNAPSHOT.jar
retention-days: 1
#Deploy's job
deploy:
#Depends on build's job
needs: build
name: Deploy Production
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
#Run on Ubuntu using the latest version
runs-on: ubuntu-latest
env:
PUSH_PACKAGES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
- name: Download JAR
if: ${{ env.PUSH_PACKAGES }}
#Download the artifact which was uploaded in the build's job
uses: actions/download-artifact@v2
with:
name: diagnosisview-api-prod
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')"
#Deploy the artifact (JAR) into AWS Beanstalk
- name: Deploy to AWS
if: ${{ env.PUSH_PACKAGES }}
uses: einaregilsson/beanstalk-deploy@v18
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: DiagnosisView
environment_name: dv-api-production
version_label: diagnosisview-api-prod:${{ steps.date.outputs.date }}
region: ${{ secrets.AWS_DEFAULT_REGION }}
deployment_package: diagnosisview-api-1.0-SNAPSHOT.jar