diff --git a/.github/workflows/publish-cloud-builder.yaml b/.github/workflows/publish-cloud-builder.yaml new file mode 100644 index 0000000..cdd657a --- /dev/null +++ b/.github/workflows/publish-cloud-builder.yaml @@ -0,0 +1,61 @@ +--- +# Automatically build Docker images using a cloud builder and publish them to a +# container registry using HCL Bake file. + +name: Build Docker Images using Cloud Builder + +on: + push: + branches: ['main'] + tags: ['*'] + +jobs: + bake-target: + name: Determine bake target + runs-on: ubuntu-22.04 # don't use the big runners for this small step + outputs: + target: ${{ steps.generate.outputs.bake_target }} + steps: + - name: Determine target + id: generate + run: | + if [[ '${{ github.event_name }}' == 'pull_request' ]]; then + TGT=default + else + TGT=prod + fi + + echo "$TGT" + echo "bake_target=${TGT,,}" >> ${GITHUB_OUTPUT} + + - name: Show Generated Target + run: echo ${{ steps.generate.outputs.bake_target }} + + # Build and Publish all targets associated with specified group + bake: + needs: + - bake-target + uses: darpa-askem/.github/.github/workflows/bake-publish-cloud-builder.yaml@main + with: + file: 'docker/docker-bake.hcl' + group: ${{ needs.bake-target.outputs.target }} + registry: 'ghcr.io' + organization: ${{ github.repository_owner }} + secrets: + username: ${{ secrets.DOCKER_CLOUD_BUILD_USERNAME }} + token: ${{ secrets.DOCKER_CLOUD_BUILD_TOKEN }} + endpoint: "${{ secrets.DOCKER_CLOUD_BUILD_ENDPOINT }}" + + # Execute simulation-integration reporting + simulation-integration: + runs-on: ubuntu-latest + needs: + - bake + steps: + - name: Report + env: + GITHUB_TOKEN: ${{ secrets.GHP_ACCESS_TOKEN }} + run: | + gh workflow run report.yaml --repo DARPA-ASKEM/simulation-integration --ref main + + diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 9585176..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,64 +0,0 @@ ---- -# Automatically build Docker images on changes to main and push them to a -# Container Registry using HCL Bake file. - -name: Build Docker Images -# yamllint disable-line rule:truthy -on: - workflow_dispatch: - push: - branches: ['main'] - tags: ['*'] - -jobs: - # Generate a more robust tag for the image - tag-generator: - name: Determine image tag - runs-on: ubuntu-22.04 - outputs: - image-tag: ${{ steps.generate.outputs.tag }} - steps: - - name: Generate appropriate tag - id: generate - run: | - if [[ '${{ github.ref_type }}' == 'branch' && '${{ github.ref_name }}' == 'main' ]]; then - TAG=latest - else - SEMVER=$( echo ${{ github.ref_name }} | sed -nre 's/^v[^0-9]*(([0-9]+\.)*[0-9]+(-[a-z]+)?).*/\1/p') - if [[ -n $SEMVER ]]; then - TAG=${SEMVER} - else - TAG=${{ github.ref_name }} - fi - fi - echo "$TAG" - echo "tag=${TAG,,}" >> ${GITHUB_OUTPUT} - - name: Show Generated Tag - run: echo ${{ steps.generate.outputs.tag }} - - # Build and Publish all targets associated with specified group - bake: - needs: - - tag-generator - uses: darpa-askem/.github/.github/workflows/bake-publish.yml@main - with: - file: 'docker/docker-bake.hcl' - group: 'prod' - registry: 'ghcr.io' - organization: ${{ github.repository_owner }} - tag: ${{ needs.tag-generator.outputs.image-tag }} - secrets: - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Execute simulation-integration reporting - simulation-integration: - runs-on: ubuntu-latest - needs: - - bake - steps: - - name: Report - env: - GITHUB_TOKEN: ${{ secrets.GHP_ACCESS_TOKEN }} - run: | - gh workflow run report.yaml --repo DARPA-ASKEM/simulation-integration --ref main diff --git a/docker/docker-bake.hcl b/docker/docker-bake.hcl index 832240d..3caefd4 100644 --- a/docker/docker-bake.hcl +++ b/docker/docker-bake.hcl @@ -36,10 +36,13 @@ group "default" { } # ---------------------------------------------------------------------------------------------------------------------- +# Used by the metafile GH action +# DO NOT ADD ANYTHING HERE THIS WILL BE POPULATED DYNAMICALLY +# MAKE SURE THIS IS INHERITED NEAR THE END SO THAT IT DOES NOT GET OVERRIDEN +target "docker-metadata-action" {} -# Removed linux/arm64 for now to ass CI build - Dec 2022 target "_platforms" { - platforms = ["linux/amd64"] + platforms = ["linux/amd64", "linux/arm64"] } target "sciml-service-base" { @@ -48,6 +51,7 @@ target "sciml-service-base" { dockerfile = "docker/Dockerfile.api" } +# NOTE: target name will be used as the name of the image target "sciml-service" { - inherits = ["_platforms", "sciml-service-base"] + inherits = ["sciml-service-base", "docker-metadata-action", "_platforms"] } \ No newline at end of file