-
Notifications
You must be signed in to change notification settings - Fork 49
83 lines (80 loc) · 3.99 KB
/
build-db-container.yml
File metadata and controls
83 lines (80 loc) · 3.99 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
on:
workflow_call:
permissions:
packages: write
jobs:
db-container:
runs-on: ubuntu-latest
name: db-container
defaults:
run:
shell: bash
steps:
- name: Check for secrets
env:
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
shell: pwsh
run: exit $(If ($env:SECRETS_AVAILABLE -eq 'true') { 0 } Else { 1 })
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5.2.0
with:
global-json-file: global.json
- name: Run MinVer
uses: Particular/run-minver-action@v1.0.0
- name: Validate build version
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: ./.github/actions/validate-version
with:
version: ${{ env.MinVerVersion }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.0.0
- name: Log in to GitHub container registry
uses: docker/login-action@v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Docker arm64 emulation
run: docker run --privileged --rm tonistiigi/binfmt --install arm64
- name: Build images
env:
TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }}
shell: pwsh
run: |
Write-Output "Determining RavenDB version from Directory.Packages.props file"
[xml]$packagesFile = Get-Content src/Directory.Packages.props
$RavenVersion = $packagesFile.selectNodes("//Project/ItemGroup/PackageVersion[@Include='RavenDB.Embedded']").Version
if (-not $RavenVersion) { throw "Unable to determine RavenDB server version from Directory.Packages.props" }
Write-Output "Determining container variants to build"
$containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json
$containers | ForEach-Object -Process {
$FULLTAG="${{ env.TAG_NAME }}-$($_.tag)"
$BASETAG="$($RavenVersion)-ubuntu.22.04-$($_.tag)"
Write-Output "::group::Building $FULLTAG for architecture $($_.arch) from $BASETAG"
docker build -t ghcr.io/particular/servicecontrol-ravendb:$FULLTAG --file src/ServiceControl.RavenDB/Dockerfile --build-arg VERSION=${{ env.MinVerVersion }} --build-arg BASETAG=$BASETAG --platform linux/$($_.arch) .
Write-Output "::endgroup::"
}
- name: List local images
run: docker images
- name: Push images to GitHub Container registry
run: docker image push --all-tags ghcr.io/particular/servicecontrol-ravendb
- name: Create multi-arch manifest
env:
TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }}
shell: pwsh
run: |
Write-Output "Creating multi-arch manifest creation command for containers specified in src/ServiceControl.RavenDB/containers.json"
$manifestCreate = "docker buildx imagetools create -t ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}"
$containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json
$containers | ForEach-Object -Process {
$manifestCreate += " ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}-$($_.tag)"
}
Write-Output "Invoking manifest creation command: > $manifestCreate"
Invoke-Expression $manifestCreate
Write-Output "Multi-arch image should now be on GitHub Container Registry at https://github.com/Particular/ServiceControl/pkgs/container/servicecontrol-ravendb/"
Write-Output "Inspecting resulting tag ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}"
docker buildx imagetools inspect ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}