-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (81 loc) · 3.47 KB
/
Copy pathci.yml
File metadata and controls
87 lines (81 loc) · 3.47 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
## A simple example to use Github Actions for Java CI with docker and maven
# We build the project using maven.
# Maven is run in a dedicated docker container
# The credentials are set as env variables in a specific ci-settings.xml
# The ENV variables are stored as Github Secrets
#
# The secrets are set in CLI with the github client.
# The following examples set them at organisation level (GITHUB_ORG variable)
# bash -c 'for secret in GITHUBLOGIN GITHUBPASSWORD DOCKER_USERNAME DOCKER_PASSWORD SONAR_URL SONAR_TOKEN; do \
# eval gh secret set $secret --app actions --body ${!secret} --org $GITHUB_ORG --visibility all; \
# done'
name: Java CI
# on every push
on: [push]
env:
GITHUBLOGIN: ${{secrets.GITHUBLOGIN}}
GITHUBPASSWORD: ${{secrets.GITHUBPASSWORD}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
SONAR_URL: ${{secrets.SONAR_URL}}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
jobs:
# This job build, test, package and deploy the artefact
maven-build:
# The tags on the runner
runs-on: [self-hosted, Linux]
steps:
#we get the content of the repository
- uses: actions/checkout@v3
# build the project in a docker container with a specific maven settings.xml
# it uses env variables from github secrets for the credentials
# to github, dockerhub and sonar.
- name: Build and test with Maven in docker
run: ./CI_Java/mvn.sh clean verify
- name: Deploy Maven Artifacts
run: ./CI_Java/mvn.sh deploy
- name: Notify dedicated teams channel of Success
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ success() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }}
notification-summary: Build and Deploy success.
notification-color: 28a745
timezone: Europe/Paris
- name: Notify dedicated teams channel of Failure
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ failure() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }}
notification-summary: Build and Deploy failure.
notification-color: dc3545
timezone: Europe/Paris
# This job publish the successsite for develop branch
maven-site:
runs-on: [self-hosted, Linux]
needs: maven-build
# Develop branch only
if: github.ref == 'refs/heads/develop'
steps:
- name: Build and deploy site with Maven
run: ./CI_Java/mvn.sh site:site site-deploy
- name: Notify dedicated teams channel of Success
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ success() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }}
notification-summary: Web site deployed.
notification-color: 28a745
timezone: Europe/Paris
- name: Notify dedicated teams channel of Failure
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ failure() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }}
notification-summary: Failed to deploy web site.
notification-color: dc3545
timezone: Europe/Paris