-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (107 loc) · 4.91 KB
/
gradle.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
name: Java CI/CD
on: [ push, pull_request ]
env:
AZURE_LOCATION: westeurope
AZURE_DNS_LABEL: scromania
jobs:
build:
name: Build & Analyze
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: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build And Scan
env:
# Sonar
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_PROJECT_KEY: sapanparikh18_FeedbackKata
SONAR_ORGANIZATION: sapanparikh18
AZUREMONITOR_INSTRUMENTATION_KEY: 96a6b51d-4026-406c-b492-b6ec81b3df91
run: |
./gradlew build --no-daemon --info -Dsonar.projectKey=sapanparikh18_FeedbackKata -Dsonar.organization=sapanparikh18
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
# - name: SonarQube Scan
# uses: sonarsource/sonarqube-scan-action@master
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# SONAR_PROJECT_KEY: sapanparikh18_FeedbackKata
# SONAR_ORGANIZATION: sapanparikh18
#
# # Check the Quality Gate status.
# - name: SonarQube Quality Gate check
# id: sonarqube-quality-gate-check
# uses: sonarsource/sonarqube-quality-gate-action@master
# # Force to fail step after specific time.
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# # Optionally you can use the output from the Quality Gate in another step.
# # The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
# - name: "SonarQube Quality Gate Status value"
# run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"
- name: Docker login
uses: docker/login-action@v1
with:
registry: ${{ secrets.DOCKER_REGISTRY_URL }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Push
env:
DOCKER_REPOSITORY_PATH: ${{ secrets.DOCKER_REPOSITORY_PATH }}
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}
TESTCONTAINERS_RYUK_DISABLED: true
run: |
export DOCKER_IMAGE=`echo "${DOCKER_REGISTRY_URL}/${DOCKER_REPOSITORY_PATH}/scromania" | sed -e 's#//#/#' -e 's#^/##'`
./gradlew dockerPush --no-daemon --info
- 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}/scromania" | sed -e 's#//#/#' -e 's#^/##'`
./gradlew build 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 scromania)
DOCKER_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" "${DOCKER_IMAGE_REPOSITORY}" )
az container create --resource-group "${AZURE_RESOURCE_GROUP}" \
--name scromania \
--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}" \
--environment-variables 'APPINSIGHTS_INSTRUMENTATIONKEY'='96a6b51d-4026-406c-b492-b6ec81b3df91' 'APPLICATIONINSIGHTS_CONNECTION_STRING'='InstrumentationKey=96a6b51d-4026-406c-b492-b6ec81b3df91;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/'