-
Notifications
You must be signed in to change notification settings - Fork 6
105 lines (79 loc) · 2.36 KB
/
docker-build-and-test.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
name: Build Templater Docker Images
on:
push:
branches:
- '*'
- '*/*'
- '**'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GO_VERSION: '1.20'
jobs:
build-dockerfiles:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up GO
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Generate Dockerfiles
run: |
go run main.go \
--config dtpl.dev.yml
- name: Upload Generated Dockerfiles
uses: actions/upload-artifact@v3
with:
name: dockerfiles
path: dockerfiles
build-dockerimages:
runs-on: ubuntu-latest
needs: build-dockerfiles
strategy:
matrix:
dockerfile: [Dockerfile.templater.dev, Dockerfile.templater.dev-debug]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Download Generated Dockerfiles
uses: actions/download-artifact@v3
with:
name: dockerfiles
path: ${{ github.workspace }}/dockerfiles
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Image Tag
run: |
echo "IMAGE_TAG=$(echo ${{ matrix.dockerfile }} | cut -d '.' -f 3)" >> $GITHUB_ENV
ls -la ${{ github.workspace }}/dockerfiles
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
context: ${{ github.workspace }}
file: ${{ github.workspace }}/dockerfiles/${{ matrix.dockerfile }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
test-dockerimages:
runs-on: ubuntu-latest
needs: build-dockerimages
strategy:
matrix:
tags: [dev, dev-debug]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test
run: |
docker run --rm \
-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tags }} \
--config dtpl.dev.yml -v -y