-
Notifications
You must be signed in to change notification settings - Fork 2
119 lines (100 loc) · 3.39 KB
/
cicd.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
111
112
113
114
115
116
117
118
119
name: Push to production ☁️
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
publish_helm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
- name: Run chart-releaser
uses: ./.github/actions/chart-releaser-action
env:
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
mark_as_latest: true
skip_existing: false
charts_dir: ./agrold-javaweb/charts
build:
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.variables.outputs.sha_short }}
build_date: ${{ steps.variables.outputs.build_date }}
no_v: ${{ steps.set_version.outputs.no_v }}
steps:
- name: Clone project
uses: actions/checkout@v3
# =============================
# This will be activated later
# =============================
# - name : Set up JDK 11
# uses: actions/setup-java@v2
# with:
# java-version: '11'
# distribution: 'adopt'
# cache: 'maven'
# - name: install dependencies
# run: mvn install -DskipTests
# - name: Run JUNIT tests
# run: mvn test
- name: Get short commit hash
id: variables
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "build_date=$(date --rfc-3339=ns)" >> $GITHUB_OUTPUT
- name: Set Versions
uses: actions/github-script@v4
id: set_version
with:
script: |
const tag = context.ref.substring(10)
const no_v = tag.replace('v', '')
core.setOutput('no_v', no_v)
build_n_push_prod:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
- name: Login to ghcr.io
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
build-args: |
AGROLD_NAME=agrold
AGROLD_DESCRIPTION="agrold production instance"
GIT_COMMIT=${{ needs.build.outputs.sha_short }}
BUILD_DATE=${{ needs.build.outputs.build_date }}
push: true
context: ./agrold-javaweb
file: ./agrold-javaweb/Dockerfile
tags: ghcr.io/southgreenplatform/agrold:${{ needs.build.outputs.no_v }},ghcr.io/southgreenplatform/agrold:latest
build_n_push_private:
needs: build
uses: ./.github/workflows/push_to_private.yml
with:
build-args: AGROLD_NAME=agrold,AGROLD_DESCRIPTION="Agrold from version ${{ needs.build.outputs.no_v }} commit ${{ needs.build.outputs.sha_short }}",GIT_COMMIT=${{ needs.build.outputs.no_v }},BUILD_DATE="${{ needs.build.outputs.build_date }}"
context: ./agrold-javaweb
dockerfile: ./agrold-javaweb/Dockerfile
image_name: agrolddev
tag: ${{ needs.build.outputs.no_v }}
registry_host: "10.9.2.21:8080"
secrets:
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}