-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 1.86 KB
/
build.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
name: Build test project
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
PROJECT_NAME: test
jobs:
init:
runs-on: self-hosted
strategy:
matrix:
target:
- go_builder
steps:
- uses: TooMuch4U/[email protected]
- uses: actions/checkout@v4
with:
submodules: true
- run: |
CURRENT_BUILD_NAME = ${{ $PROJECT_NAME }}_base:${{ matrix.target }}
docker build -f ./base.Dockerfile \
-t ${{ CURRENT_BUILD_NAME }} \
--target ${{ matrix.target }} \
--tag base:${{ matrix.target }}
--cache-from type=gha,scope=${{ CURRENT_BUILD_NAME }} \
--cache-to type=gha,mode=max,scope=${{ CURRENT_BUILD_NAME }} \
.
backend:
runs-on: self-hosted
permissions:
contents: read
packages: write
needs:
- init
strategy:
matrix:
target:
- pingserver
steps:
- uses: TooMuch4U/[email protected]
- uses: actions/checkout@v4
- name: Login to GitHub Package Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u "${{ github.actor }}" --password-stdin
- name: Start build ${{ $PROJECT_NAME }} - ${{ matrix.target }}
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ $PROJECT_NAME }}-${{ matrix.target }}
echo START BUILD WITH IMAGE_ID=$IMAGE_ID
PATH_TO_MAIN=./apps/${{ matrix.target }}
echo PATH_TO_MAIN=$PATH_TO_MAIN
docker build -f $PATH_TO_MAIN/Dockerfile \
--build-arg PATH_TO_MAIN=$PATH_TO_MAIN \
--tag $IMAGE_ID:latest \
# --cache-from type=gha \
# --cache-to type=gha,mode=max \
-t ${{ $PROJECT_NAME }}:${{ matrix.target }} \
.
docker push $IMAGE_ID:latest