Skip to content

Commit

Permalink
Test composite build action
Browse files Browse the repository at this point in the history
  • Loading branch information
sixeyed committed Dec 30, 2024
1 parent 1c8f248 commit d3d79a6
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 23 deletions.
27 changes: 27 additions & 0 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Build'
description: 'Build & push images'
inputs:
images:
description: 'Build base images'
required: false
default: true
chapters:
description: 'Build chapter images'
required: false
default: false
filter:
description: 'Filter image to build'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Build and push images
working-directory: build
shell: pwsh
run: |
./build.ps1
env:
BUILD_IMAGES: ${{ inputs.images }}
BUILD_CHAPTERS: ${{ inputs.chapters }}
FILTER: ${{ inputs.filter }}
15 changes: 5 additions & 10 deletions .github/workflows/images-linux-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ jobs:

- uses: actions/checkout@master

- name: Build and push base images
working-directory: build
shell: pwsh
run: |
./build.ps1 -Images
- uses: .github/actions/build

- name: Build and push chapter images
working-directory: build
shell: pwsh
run: |
./build.ps1 -Chapters
- uses: .github/actions/build
with:
images: false
chapters: true
46 changes: 33 additions & 13 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ param(

$ErrorActionPreference = 'Continue'

if ($env:BUILD_IMAGES) {
$Images = [bool]$env:BUILD_IMAGES
}
if ($env:BUILD_CHAPTERS) {
$Chapters = [bool]$env:BUILD_CHAPTERS
}
if ($env:FILTER) {
$Filter = $env:FILTER
}

try {
$info = docker version -f json | ConvertFrom-Json
$env:DOCKER_BUILD_OS = $info.Server.Os.ToLower()
Expand All @@ -28,6 +38,12 @@ try {
$env:OS_VERSION_TAG="-$env:WINDOWS_VERSION"
}

echo '------------------'
echo 'Build info'
echo '------------------'
echo "Images = $Images"
echo "Chapters = $Chapters"
echo "Filter = $Filter"
echo '------------------'
echo 'OS info'
echo '------------------'
Expand All @@ -42,28 +58,32 @@ try {
if ($Chapters) {
$collection='chapters'
}

$compose="compose-$collection"
$composeFile="${compose}.yml"
$osFile="${compose}-$($env:DOCKER_BUILD_OS).yml"
$tagsFile="${compose}-tags.yml"

$composeFiles = @(
'-f', $composeFile,
'-f', $osFile,
'-f', $tagsFile
)

# Windows dependency
if ($env:DOCKER_BUILD_OS -eq 'windows') {
docker compose -f $composeFile -f $osFile -f $tagsFile build --pull git-windows
docker compose -f $composeFile -f $osFile -f $tagsFile push git-windows
docker compose $composeFiles build --pull git-windows
docker compose $composeFiles push git-windows
}

docker compose `
-f $composeFile `
-f $osFile `
-f $tagsFile `
build --pull #$Filter

docker compose `
-f $composeFile `
-f $osFile `
-f $tagsFile `
push #$Filter
if ($Filter -and ($Filter -ne '')) {
docker compose $composeFiles build --pull $Filter
docker compose $composeFiles push $Filter
}
else {
docker compose $composeFiles build --pull
docker compose $composeFiles push
}
}

finally {
Expand Down

0 comments on commit d3d79a6

Please sign in to comment.