-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (76 loc) · 2.28 KB
/
ci.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
name: Build and Publish Docker image
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
metadata:
permissions:
packages: write
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
continue: ${{ steps.generate-matrix.outputs.continue }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: generate matrix
id: generate-matrix
run: |
bash generate_matrix.sh
docker:
if: needs.metadata.outputs.continue == 'yes'
needs: metadata
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to GHCR
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/frezbo/${{ matrix.project }}
flavor: |
latest=false
tags: |
type=raw,enable=true,value=${{ matrix.version }}
labels: |
org.opencontainers.image.version=${{ matrix.version }}
- name: build/push
uses: docker/[email protected]
env:
CONTEXT: ${{ matrix.project }}
DOCKERFILE: Dockerfile
VERSION: ${{ matrix.version }}
LOAD_IMAGE_IN_CI: ${{ github.event_name == 'pull_request' }}
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: build
pull: true
load: ${{ github.event_name == 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }}
- name: test
if: github.event_name == 'pull_request'
run: |
set -eu -o pipefail
if [[ -e ${{ matrix.project }}/test.sh ]]; then
bash ${{ matrix.project }}/test.sh ${{ matrix.project }} ${{ matrix.version }}
fi