-
Notifications
You must be signed in to change notification settings - Fork 8
126 lines (111 loc) · 3.83 KB
/
docker-build-and-publish.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
120
121
122
123
124
125
126
name: Docker Build and Publish
on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- "images/**"
schedule:
- cron: "0 2 * * 0" # Weekly on Sundays at 02:00
permissions:
contents: read
packages: write
id-token: write
env:
IMAGE_TAG: 1.0.${{ github.run_number }}
jobs:
build-standard:
name: Build standard images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and publish standard alpine
id: publish-standard-alpine
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: SlalomBuild/pe-toolkit-standard-alpine
dockerfile: images/dockerfile-standard-alpine
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
buildoptions: "--compress --force-rm"
platforms: linux/amd64,linux/arm64
tags: "latest,${{ env.IMAGE_TAG }},alpine"
- name: Build and publish standard ubuntu
id: publish-standard-ubuntu
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: SlalomBuild/pe-toolkit-standard-ubuntu
dockerfile: images/dockerfile-standard-ubuntu
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
buildoptions: "--compress --force-rm"
platforms: linux/amd64,linux/arm64
tags: "latest,${{ env.IMAGE_TAG }},ubuntu"
build-full:
name: Build full images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and publish full ubuntu
id: publish-full-ubuntu
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: SlalomBuild/pe-toolkit-full-ubuntu
dockerfile: images/dockerfile-full-ubuntu
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
buildoptions: "--compress --force-rm"
platforms: linux/amd64,linux/arm64
tags: "latest,${{ env.IMAGE_TAG }},ubuntu"
- name: Build and publish full alpine
id: publish-full-alpine
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: SlalomBuild/pe-toolkit-full-alpine
dockerfile: images/dockerfile-full-alpine
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
buildoptions: "--compress --force-rm"
platforms: linux/amd64,linux/arm64
tags: "latest,${{ env.IMAGE_TAG }},alpine"
# _____ _
# |_ _|__ ___| |_ ___
# | |/ _ \/ __| __/ __|
# | | __/\__ \ |_\__ \
# |_|\___||___/\__|___/
test:
name: Test ${{ matrix.type.name }}-${{ matrix.distro.id }}-${{ matrix.arch.id }}
if: ${{ success() }}
needs: [build-standard, build-full]
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- id: "amd64"
- id: "arm64"
distro:
- id: "ubuntu"
- id: "alpine"
type:
- name: "full"
- name: "standard"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "linux/${{ matrix.arch.id }}"
- name: Run binaries in docker
run: |
docker run \
--rm \
--platform linux/${{ matrix.arch.id }} \
ghcr.io/slalombuild/pe-toolkit-${{ matrix.type.name }}-${{ matrix.distro.id }}:${{ env.IMAGE_TAG }} \
/bin/sh -c 'figlet terraform && terraform version && figlet atmos && atmos version && figlet tflint && tflint --version && figlet tfsec && tfsec --version && figlet opa && opa version'