-
Notifications
You must be signed in to change notification settings - Fork 10
120 lines (113 loc) · 3.96 KB
/
Copy pathapi.atm-locator.deploy.yml
File metadata and controls
120 lines (113 loc) · 3.96 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
name: Deploy ATM-Locator
env:
appId: atm-locator-app
working-directory: atm-locator
dockerRegistry: ghcr.io
dockerRepository: cwiechmann/axway-api-management-automated
on:
push:
branches:
- main
paths:
- atm-locator/**
pull_request:
branches:
- main
paths:
- atm-locator/**
defaults:
run:
working-directory: atm-locator
jobs:
create-latest-docker-image:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Create App Docker-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 app')"
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-application:
name: Deploy ATM-Locator application
needs: create-latest-docker-image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- 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/app-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 app')"
run: |
mkdir $HOME/.kube
echo "${{ secrets.KUBE_CONFIG_DATA }}" | base64 -d > $HOME/.kube/config
kubectl apply -n apim -f config/app-deployment.yaml
timeout-minutes: 2
- name: Verify deployment
if: "!contains(github.event.head_commit.message, 'skip app')"
run: kubectl -n apim rollout status deployment/${{ env.appId }}
timeout-minutes: 2
deploy-api:
name: API-Deployment
needs: deploy-application
runs-on: ubuntu-latest
steps:
#- name: Debug
# uses: hmarr/debug-action@v1.0.0
- 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
if: ${{ github.event_name != 'pull_request' }}
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: Test API
run: |
sleep 1
newman run ./tests/ATM-Locator-API.postman_collection.json -e ../lib/Demo-Environment.postman_environment.json --reporter-json-export output.json --insecure