-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (59 loc) · 2.31 KB
/
azure-container-instance.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
name: Azure Container Instance Java CD
on: [push, pull_request]
env:
AZURE_LOCATION: westeurope
AZURE_DNS_LABEL: Bank
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: ${{ runner.os }}-gradle-test-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-test-
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Docker login
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build And Push Docker Image
env:
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
DOCKER_REPOSITORY_PATH: ${{ secrets.DOCKER_REPOSITORY_PATH }}
TESTCONTAINERS_RYUK_DISABLED: true
run: |
export DOCKER_IMAGE=`echo "${DOCKER_REGISTRY_URL}/${DOCKER_REPOSITORY_PATH}/Bank" | sed -e 's#//#/#' -e 's#^/##'`
./gradlew check dockerPush --no-daemon
- name: Deploy to Azure Container Instances
env:
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
DOCKER_IMAGE_REPOSITORY=$(docker images --format "{{.Repository}}" | grep Bank)
DOCKER_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" "${DOCKER_IMAGE_REPOSITORY}" )
az container create --resource-group "${AZURE_RESOURCE_GROUP}" \
--name Bank \
--registry-login-server "${DOCKER_REGISTRY_URL}" \
--registry-username "${DOCKER_USERNAME}" \
--registry-password "${DOCKER_PASSWORD}" \
--image "${DOCKER_IMAGE}" \
--dns-name-label "${AZURE_DNS_LABEL}" \
--ports 8080 \
--location "${AZURE_LOCATION}"