This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
Docker Image CI #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
push: | |
branches: [ main ] | |
schedule: | |
- cron: '0 5 * * *' | |
workflow_dispatch: | |
jobs: | |
get-version-number: | |
runs-on: windows-latest | |
outputs: | |
LIQUIBASE_VERSION: ${{ steps.step1.outputs.CURRENT_LIQUIBASE_VERSION }} | |
CONTINUE: ${{ steps.step1.outputs.Continue }} | |
WIN2019_VERSION: ${{ steps.step1.outputs.WIN2019_VERSION }} | |
WIN2022_VERSION: ${{ steps.step1.outputs.WIN2022_VERSION }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: step1 | |
name: Compare latest liquibase version with container | |
run: | | |
$Repository = "liquibase/liquibase" | |
$releasesUrl = "https://api.github.com/repos/$Repository/releases" | |
$tags = (Invoke-WebRequest $releasesUrl -UseBasicParsing | ConvertFrom-Json) | |
$latestLiquibaseVersion = $null | |
foreach ($tag in $tags) { | |
if ($tag.assets.Count -gt 0) { | |
$latestLiquibaseVersion = ($tag.tag_name.Replace("v", "")) | |
} | |
} | |
$workerToolsTags = (Invoke-RestMethod "https://registry.hub.docker.com/v2/repositories/octopuslabs/liquibase-workertools/tags?page_size=50") | |
$matchingTag = $workerToolsTags.results | Where-Object { $_.name -eq $latestLiquibaseVersion } | |
echo "CURRENT_LIQUIBASE_VERSION=$latestLiquibaseVersion" >> $env:GITHUB_OUTPUT | |
if ($null -ne $matchingTag) | |
{ | |
Write-Host "Docker container already has latest version of liquibase" | |
echo "CONTINUE=No" >> $env:GITHUB_OUTPUT | |
} | |
else | |
{ | |
Write-Host "We need to upgrade the liquibase container to $latestLiquibaseVersion" | |
<# Write-Host "Getting OS versions for windows 2022 and 2019" | |
$win2019_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2019" | ConvertFrom-Json) | |
$WIN2019_VERSION = $win2019_manifest.Descriptor.Platform.'os.version' | |
Write-Host "WIN2019_VERSION: $WIN2019_VERSION" | |
$win2022_manifest = (docker manifest inspect --verbose "octopuslabs/workertools:latest-windows.2022" | ConvertFrom-Json) | |
$WIN2022_VERSION = $win2022_manifest.Descriptor.Platform.'os.version' | |
Write-Host "WIN2022_VERSION: $WIN2022_VERSION" | |
if([string]::IsNullOrWhiteSpace($WIN2019_VERSION) -or [string]::IsNullOrWhiteSpace($WIN2022_VERSION)) { | |
throw "Could not establish OS versions for windows 2022 and 2019 needed for docker manifest" | |
} | |
echo "WIN2019_VERSION=$WIN2019_VERSION" >> $env:GITHUB_OUTPUT | |
echo "WIN2022_VERSION=$WIN2022_VERSION" >> $env:GITHUB_OUTPUT | |
#> | |
Write-Host "We have everything we need, continuing." | |
echo "CONTINUE=Yes" >> $env:GITHUB_OUTPUT | |
} | |
shell: powershell | |
build-ubuntu: | |
needs: [get-version-number] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: DockerHub Login | |
env: | |
USERNAME: ${{ secrets.DOCKER_HUB_USER }} | |
PASSWORD: ${{ secrets.DOCKER_HUB_PAT }} | |
run: docker login --username $USERNAME --password "$PASSWORD" | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Build the ubuntu.2004 image | |
env: | |
LIQUIBASE_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.LIQUIBASE_VERSION }} | |
run: docker build ./ubuntu-2004 --tag octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD-ubuntu.2004 --tag octopuslabs/liquibase-workertools:latest-ubuntu.2004 --build-arg FLYWAY_VERSION=$LIQUIBASE_VERSION_TO_BUILD | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2004 version-specific image | |
env: | |
LIQUIBASE_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.LIQUIBASE_VERSION }} | |
run: docker push octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD-ubuntu.2004 | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2004 latest image | |
run: docker push octopuslabs/liquibase-workertools:latest-ubuntu.2004 | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Build the ubuntu.2204 image | |
env: | |
LIQUIBASE_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.LIQUIBASE_VERSION }} | |
run: docker build ./ubuntu-2204 --tag octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD-ubuntu.2204 --tag octopuslabs/liquibase-workertools:latest-ubuntu.2204 --tag octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD --tag octopuslabs/liquibase-workertools:latest --build-arg FLYWAY_VERSION=$LIQUIBASE_VERSION_TO_BUILD | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2204 version-specific image | |
env: | |
LIQUIBASE_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.LIQUIBASE_VERSION }} | |
run: docker push octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD-ubuntu.2204 | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2204 latest image | |
run: docker push octopuslabs/liquibase-workertools:latest-ubuntu.2204 | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2204 version speciefic | |
env: | |
LIQUIBASE_VERSION_TO_BUILD: ${{ needs.get-version-number.outputs.LIQUIBASE_VERSION }} | |
run: docker push octopuslabs/liquibase-workertools:$LIQUIBASE_VERSION_TO_BUILD | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} | |
- name: Push the ubuntu.2204 latest image | |
run: docker push octopuslabs/liquibase-workertools:latest | |
if: ${{ needs.get-version-number.outputs.CONTINUE == 'Yes' }} |