Publish to Docker Hub #6178
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
# SPDX-License-Identifier: Apache-2.0 | |
# Licensed to the Ed-Fi Alliance under one or more agreements. | |
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | |
# See the LICENSE and NOTICES files in the project root for more information. | |
name: Publish to Docker Hub | |
on: | |
workflow_run: | |
workflows: | |
- "Docker Test" | |
types: | |
- completed | |
branches: | |
[main, 'b-v*-patch*','feature-*'] | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
package_version: | |
description: 'Package Version' | |
required: true | |
default: "7.4" | |
type: string | |
permissions: read-all | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} | |
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} | |
REPOSITORY_OWNER: ${{ GITHUB.REPOSITORY_OWNER }} | |
CURRENT_STANDARD_VERSION: "5.2.0" | |
PACKAGE_VERSION: "7.4" | |
EVENT_NAME: ${{ GITHUB.EVENT_NAME }} | |
EVENT_ACTION: ${{ GITHUB.EVENT.ACTION }} | |
BASE_BRANCH: ${{ GITHUB.HEAD_REF || GITHUB.REF_NAME }} | |
jobs: | |
assert-all-required-workflows-succeeded: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: ahmadnassri/action-workflow-run-wait@2aa3d9e1a12ecaaa9908e368eaf2123bb084323e #v1.4.4 | |
with: | |
timeout: 1800000 | |
delay: 60000 | |
ignore-cancelled: true # Treat canceled as success | |
FindStandardAndExtensionVersions: | |
needs: assert-all-required-workflows-succeeded | |
uses: Ed-Fi-Alliance-OSS/Ed-Fi-ODS/.github/workflows/Find Standard and Extension Versions.yml@874b608a0f3a14243e0035dd1222169fafcbe8d3 | |
with: | |
calling_branch: ${{ github.head_ref || github.ref_name }} | |
docker-publish: | |
if: (needs.FindStandardAndExtensionVersions.outputs.StandardVersions != '' && | |
needs.FindStandardAndExtensionVersions.outputs.ExtensionVersions != '') | |
needs: FindStandardAndExtensionVersions | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
StandardVersion: ${{ fromJson(needs.FindStandardAndExtensionVersions.outputs.StandardVersions) }} | |
ExtensionVersion: ${{ fromJson(needs.FindStandardAndExtensionVersions.outputs.ExtensionVersions) }} | |
dockerfile: | |
[ | |
{ name: "ods-api-bulk-load-console", path: "alpine" }, | |
{ name: "ods-api-db-admin", path: "alpine/pgsql" }, | |
{ name: "ods-api-db-ods-minimal", path: "alpine/pgsql" }, | |
{ name: "ods-api-db-ods-sandbox", path: "alpine/pgsql" }, | |
{ name: "ods-api-swaggerui", path: "alpine" }, | |
{ name: "ods-api-web-api", path: "alpine/pgsql" }, | |
{ name: "ods-api-web-api", path: "alpine/mssql" }, | |
{ name: "ods-api-web-sandbox-admin", path: "alpine/pgsql" }, | |
{ name: "ods-api-web-sandbox-admin", path: "alpine/mssql" } | |
] | |
name: ${{ matrix.dockerfile.name }}/${{ matrix.dockerfile.path }} Image for (Standard ${{ matrix.StandardVersion }} Extension ${{ matrix.ExtensionVersion }}) | |
steps: | |
- name: Check for Docker Hub Token | |
if: ${{ env.REPOSITORY_OWNER == 'Ed-Fi-Alliance-OSS' && env.DOCKER_HUB_TOKEN == '' }} | |
run: | | |
echo "::error::Missing Docker Hub Token" | |
exit 1 | |
- name: Exit success if Docker Hub Token is missing in forked repository | |
if: ${{ env.DOCKER_HUB_TOKEN == '' }} | |
run: | | |
echo "Skipping Publish" | |
- name: Wait 20s for Azure Artifacts caching | |
run: sleep 20 | |
- name: Checkout Repository | |
if: ${{ env.DOCKER_HUB_TOKEN != '' }} | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Log in to Docker Hub | |
if: ${{ env.DOCKER_HUB_TOKEN != '' }} | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_HUB_TOKEN }} | |
- name: Build ${{ matrix.dockerfile.name }} image in path ${{ matrix.dockerfile.path }} and Push | |
if: ${{ env.DOCKER_HUB_TOKEN != '' }} | |
run: | | |
# Note: all images will receive the same version number for this Docker release | |
if (($env:EVENT_NAME -eq "release" -and $env:EVENT_ACTION -eq "published") -or ($env:EVENT_NAME -eq "workflow_dispatch")) { | |
$package_version="${{ env.PACKAGE_VERSION }}" | |
if ($env:EVENT_NAME -eq "workflow_dispatch") { | |
$package_version="${{ inputs.package_version }}" | |
} | |
./get-versions.ps1 -PackageVersion $package_version -StandardVersion ${{ matrix.StandardVersion }} -ExtensionVersion ${{ matrix.ExtensionVersion }} | |
./Invoke-Build.ps1 -Push -PackageVersion $package_version -Patch ${{ github.run_number }} -ImageName ${{ matrix.dockerfile.name }} -Path ${{ matrix.dockerfile.path }} | |
Write-Host "This step is triggered manually or by a published release." | |
} | |
else | |
{ | |
./get-versions.ps1 -PackageVersion ${{ env.PACKAGE_VERSION }} -StandardVersion ${{ matrix.StandardVersion }} -ExtensionVersion ${{ matrix.ExtensionVersion }} -PreRelease | |
./Invoke-Build.ps1 -Push -PackageVersion ${{ env.PACKAGE_VERSION }} -Patch ${{ github.run_number }} -PreRelease -ImageName ${{ matrix.dockerfile.name }} -Path ${{ matrix.dockerfile.path }} | |
} | |
working-directory: Docker | |
shell: pwsh |