-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (142 loc) · 5.33 KB
/
Copy pathbuild-container-reusable.yml
File metadata and controls
144 lines (142 loc) · 5.33 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build Container - Reusable
on:
workflow_call:
inputs:
container-runtime:
required: true
type: string
runtime:
required: true
type: string
test-group-name:
required: false
type: string
default: all
mode:
required: false
type: string
default: build-and-test
test-image-artifact-name:
required: false
type: string
default: eventstore-test-image
image-artifact-name:
required: false
type: string
default: eventstore-image
jobs:
build-container:
strategy:
fail-fast: false
runs-on: ubuntu-latest
name: ${{ format('{0} / {1}', inputs.container-runtime, inputs.test-group-name) }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install task runner
id: mise
uses: jdx/mise-action@v4.2.3
with:
version: 2026.8.2
install: false
cache: false
- name: Install net10.0
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
if: ${{ inputs.mode != 'test-only' }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v4
if: ${{ inputs.mode != 'test-only' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
if: ${{ inputs.mode != 'test-only' }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
if: ${{ inputs.mode != 'test-only' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v7
if: ${{ inputs.mode != 'test-only' }}
with:
context: .
load: true
tags: eventstore
build-args: |
CONTAINER_RUNTIME=${{ inputs.container-runtime }}
RUNTIME=${{ inputs.runtime }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
cache-from: type=gha,scope=${{ format('container-{0}-{1}', inputs.container-runtime, inputs.runtime) }}
cache-to: type=gha,mode=max,scope=${{ format('container-{0}-{1}', inputs.container-runtime, inputs.runtime) }}
secrets: |
nuget_auth_token=${{ secrets.GITHUB_TOKEN }}
- name: Verify Build
if: ${{ inputs.mode != 'test-only' }}
run: mise run --skip-tools github-actions:container -- verify
- name: Build Test Container
uses: docker/build-push-action@v7
if: ${{ inputs.mode != 'test-only' }}
with:
context: .
load: true
target: test
tags: eventstore-test
build-args: |
CONTAINER_RUNTIME=${{ inputs.container-runtime }}
RUNTIME=${{ inputs.runtime }}
cache-from: type=gha,scope=${{ format('container-{0}-{1}', inputs.container-runtime, inputs.runtime) }}
cache-to: type=gha,mode=max,scope=${{ format('container-{0}-{1}', inputs.container-runtime, inputs.runtime) }}
secrets: |
nuget_auth_token=${{ secrets.GITHUB_TOKEN }}
- name: Export Test Container
if: ${{ inputs.mode == 'build-only' }}
run: mise run --skip-tools github-actions:container -- export-test
- name: Export Container
if: ${{ inputs.mode == 'build-only' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
run: mise run --skip-tools github-actions:container -- export-runtime
- name: Publish Test Container
uses: actions/upload-artifact@v7
if: ${{ inputs.mode == 'build-only' }}
with:
name: ${{ inputs.test-image-artifact-name }}
path: eventstore-test.tar
if-no-files-found: error
retention-days: 1
- name: Publish Container
uses: actions/upload-artifact@v7
if: ${{ inputs.mode == 'build-only' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
with:
name: ${{ inputs.image-artifact-name }}
path: eventstore.tar
if-no-files-found: error
retention-days: 1
- name: Download Test Container
uses: actions/download-artifact@v8
if: ${{ inputs.mode == 'test-only' }}
with:
name: ${{ inputs.test-image-artifact-name }}
- name: Load Test Container
if: ${{ inputs.mode == 'test-only' }}
run: mise run --skip-tools github-actions:container -- load-test
- name: Run Tests
if: ${{ inputs.mode != 'build-only' }}
env:
TEST_GROUP: ${{ inputs.test-group-name }}
run: mise run --skip-tools github-actions:container -- test
- name: Normalize Test Result Permissions
if: ${{ failure() && steps.mise.outcome == 'success' }}
run: mise run --skip-tools github-actions:container -- normalize-results
- name: Publish Test Results
uses: actions/upload-artifact@v7
if: failure()
with:
name: test-results-${{ inputs.container-runtime }}-${{ inputs.test-group-name }}
path: test-results
if-no-files-found: ignore