-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (88 loc) · 2.71 KB
/
container-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
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
name: Container build
"on":
release:
types:
- released
workflow_dispatch:
jobs:
prepare-matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.matrix.outputs.output }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: fabasoad/data-format-converter-action@main
id: matrix
with:
input: ".github/container-matrix.yml"
from: "yaml"
to: "json"
build:
name: Build container
runs-on: ubuntu-22.04
needs: prepare-matrix
strategy:
# fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Process ansible core image version
id: core-image
run: |
CORE_VERSION=$(./run.sh _transformAnsibleCoreVersion "${{ matrix.ansible-core-image }}")
echo "core-version=$CORE_VERSION" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ steps.core-image.outputs.core-version }}
tags: |
type=ref,event=tag
type=ref,event=branch
# git short commit
type=sha
- name: Build
uses: docker/build-push-action@v4
with:
context: .
load: true
build-args: |
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }}
tags: app:latest
- name: Test
run: |
sudo docker run --rm app:latest ansible-galaxy collection list | grep -q 'nokia.srlinux' || exit 1
- name: Login to GitHub Container Registry
if: "!github.event.act"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: "!github.event.act"
uses: docker/setup-qemu-action@v3
- name: Build and Push
if: "!github.event.act"
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=ghcr.io/srl-labs/ansible-core/${{ matrix.ansible-core-image }}
tags: ${{ steps.meta.outputs.tags }}