-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (96 loc) · 3.39 KB
/
docker-image.yaml
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: Docker CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
build-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get date
id: date
run: |
echo "DATE=$(date +'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | head -c 7)" >> $GITHUB_ENV
- name: Get branch name
id: branch
run: |
BRANCH_NAME="${{ github.head_ref }}"
if [[ -z "$BRANCH_NAME" ]]; then
BRANCH_NAME="${{ github.ref }}"
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
fi
BRANCH_NAME=$(echo $BRANCH_NAME | tr / -)
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Set release code
if: (success() || failure())
id: releasecode
run: |
VERSION=$(grep APP_VERSION= .env | cut -d '=' -f2)
RELEASE=$BRANCH_NAME-$DATE
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
echo "APP_ENV=prod">> $GITHUB_ENV
echo "APP_BUILD=latest">> $GITHUB_ENV
echo "set APP_ENV to $APP_ENV"
- name: Setting CONTAINER_PROJECT_NAME
run: |
NAME=$(grep CONTAINER_PROJECT_NAME= .env | cut -d '=' -f2)
echo "CONTAINER_PROJECT_NAME=$NAME" >> $GITHUB_ENV
- name: Setting CONTAINER_REGISTRY_BASE
run: |
NAME=$(grep CONTAINER_REGISTRY_BASE= .env | cut -d '=' -f2)
echo "CONTAINER_REGISTRY_BASE=$NAME" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'
- name: Build containers
uses: docker/bake-action@v3
with:
push: false
load: true
files: docker-compose.deploy.yaml
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: copy testresults
uses: docker/build-push-action@v4
with:
push: false
load: false
context: .
file: Kiss.Bff/Dockerfile
target: test
outputs: testresults
- name: dotnet test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: dotnet tests # Name of the check run which will be created
path: testresults/*.trx # Path to test results
reporter: dotnet-trx # Format of test results
- name: npm test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: npm tests # Name of the check run which will be created
path: testresults/*.xml # Path to test results
reporter: jest-junit # Format of test results
- name: push image
uses: docker/build-push-action@v4
if: github.event_name != 'pull_request'
with:
context: .
file: Kiss.Bff/Dockerfile
push: true
tags: ${{ env.CONTAINER_REGISTRY_BASE }}/${{ env.CONTAINER_PROJECT_NAME }}:${{ env.RELEASE}},${{ env.CONTAINER_REGISTRY_BASE }}/${{ env.CONTAINER_PROJECT_NAME }}:latest
target: final