-
Notifications
You must be signed in to change notification settings - Fork 48
67 lines (65 loc) · 3.29 KB
/
build-db-container.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
on:
workflow_call:
jobs:
db-container:
runs-on: ubuntu-22.04
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@v4.2.2
with:
fetch-depth: 0
- 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: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- 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: |
$manifestCreate = "docker manifest create ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}"
$containers = cat src/ServiceControl.RavenDB/containers.json | ConvertFrom-Json
$containers | ForEach-Object -Process {
$manifestCreate += " --amend ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}-$($_.tag)"
}
Invoke-Expression $manifestCreate
docker buildx imagetools inspect ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}
docker manifest push ghcr.io/particular/servicecontrol-ravendb:${{ env.TAG_NAME }}