-
Notifications
You must be signed in to change notification settings - Fork 10
165 lines (156 loc) · 5.24 KB
/
Copy pathapi.emr-diagnostic.deploy.yml
File metadata and controls
165 lines (156 loc) · 5.24 KB
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
name: EMR-Diagnotics API
env:
appId: api-emr-diagnostic
working-directory: api-emr-diagnostic
dockerRegistry: ghcr.io
dockerRepository: Axway-API-Management-Plus/axway-api-management-automated
on:
push:
branches:
- main
paths:
- api-emr-diagnostic/**
release:
types:
- published
tags:
- '*api-emr-diagnostic*'
defaults:
run:
working-directory: api-emr-diagnostic
jobs:
create-latest-docker-image:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Create API-Builder Image
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v2
- name: Check out the repo
uses: actions/checkout@v2
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
registry: ${{ env.dockerRegistry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create image tag
run: echo "IMAGE_TAG=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_ENV
- name: Build container image
if: "!contains(github.event.head_commit.message, 'skip builder')"
uses: docker/build-push-action@v2
with:
context: ./${{ env.working-directory }}/${{ env.appId }}
file: ./${{ env.working-directory }}/${{ env.appId }}/Dockerfile
push: true
tags: ${{ env.dockerRegistry }}/${{ env.dockerRepository }}/${{ env.appId }}:${{ env.IMAGE_TAG }}
deploy-api-builder:
name: Deploy API-Builder application
needs: create-latest-docker-image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: List current directory
run: ls -l
- name: Update deployment file
run: IMAGE_TAG=$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|${{ env.dockerRegistry }}/${{ env.dockerRepository }}/${{ env.appId }}:'${IMAGE_TAG}'|' config/api-deployment.yaml
- name: Configure AWS credentials
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: eu-west-1
- name: Deploy to Kubernetes
if: "!contains(github.event.head_commit.message, 'skip builder')"
run: |
mkdir $HOME/.kube
echo "${{ secrets.KUBE_CONFIG_DATA }}" | base64 -d > $HOME/.kube/config
kubectl apply -n apim -f config/api-deployment.yaml
timeout-minutes: 2
- name: Verify deployment
if: "!contains(github.event.head_commit.message, 'skip builder')"
run: kubectl -n apim rollout status deployment/${{ env.appId }}
timeout-minutes: 2
deploy-api:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Deploy API on API-Management
runs-on: ubuntu-latest
needs: deploy-api-builder
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy API
env:
APIM_USER: ${{ secrets.APIM_USER }}
APIM_PASS: ${{ secrets.APIM_PASS }}
APIM_HOST: ${{ secrets.APIM_HOST }}
APIM_PORT: ${{ secrets.APIM_PORT }}
run: mvn clean exec:java
test-api:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Test API
runs-on: ubuntu-latest
needs: deploy-api
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install newman
run: sudo npm -g install newman
- name: Run API tests
run: |
sleep 1
newman run ./tests/DiagnosticAPI.postman_collection.json -e ../lib/Demo-Environment.postman_environment.json --reporter-json-export output.json --insecure
# Publish-API:
# runs-on: ubuntu-latest
# needs: API-Deployment
# steps:
# - uses: hmarr/debug-action@v2
# - name: Publish package
# run: mvn --batch-mode deploy
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Release-API:
if: github.event.release.tag_name
runs-on: ubuntu-latest
needs: test-api
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github
- name: Configure Git user
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
- name: List current directory
run: |
ls -la
- name: Release prepare
run: |
git status
mvn -B -f api-emr-diagnostic/pom.xml release:prepare
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List current directory
run: |
ls -la
- name: Release perform
run: |
mvn -B -f api-emr-diagnostic/pom.xml release:perform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}