Skip to content

Commit

Permalink
fix: Docker workflow (meltano#6593)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillDaSilva committed Aug 9, 2022
1 parent 25c0aed commit 8e8e4a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
32 changes: 17 additions & 15 deletions .github/actions/docker-build-scan-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ inputs:
tags:
description: 'The Docker tags for the image that will be built'
required: true
build-args:
description: 'The Docker build args'
required: true
registry:
description: "Where to upload the images"
required: true
Expand All @@ -24,7 +21,10 @@ inputs:
description: 'The password to use when pushing the image'
required: true
python-version:
description: 'The Python version installed on the image'
description: 'The version of Python that will be installed on the image'
required: true
meltano-version:
description: 'The version of Meltano that will be installed on the image'
required: true

runs:
Expand All @@ -34,21 +34,23 @@ runs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build the image
uses: docker/build-push-action@v3
with:
load: true
context: "{{defaultContext}}:docker/meltano"
tags: ${{ inputs.tags }}
build-args: ${{ inputs.build-args }}
shell: bash
run: |
BUILD_CMD="docker build \
--build-arg PYTHON_VERSION=${{ inputs.python-version }} \
--build-arg MELTANO_VERSION=${{ inputs.meltano-version }} \
$(echo "${{ inputs.tags }}" | sed "s/^/-t ${{ inputs.registry }}\/meltano\/meltano:/" | tr '\n' ' ') \
docker/meltano"
echo "${BUILD_CMD}"
eval "${BUILD_CMD}"
- name: Get the ID of the image
id: get-image-id
shell: bash
run: echo "::set-output name=id::$(docker images -q meltano/meltano | head -n 1)"
run: |
docker images
echo "::set-output name=id::$(docker images -q ${{ inputs.registry }}/meltano/meltano | head -n 1)"
- name: Scan the image with 'anchore/scan-action'
id: anchore-scan
Expand Down Expand Up @@ -87,4 +89,4 @@ runs:
- name: Push the scanned image to the registry
if: ${{ inputs.push == 'true' }}
shell: bash
run: docker image push --all-tags meltano/meltano
run: docker image push --all-tags ${{ inputs.registry }}/meltano/meltano
27 changes: 7 additions & 20 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
public_docker_build:
runs-on: ubuntu-latest
env:
IMAGE_NAME: meltano/meltano
COMMIT_SHA: ${{ github.sha }}
# Boolean values don't actually work so cast to 'true' and 'false'
# https://github.com/actions/runner/issues/1483
DRY_RUN_STR: ${{ format('{0}', github.event.inputs.dry-run) || 'true' }}
Expand Down Expand Up @@ -53,15 +51,6 @@ jobs:
poetry version --short
echo "::set-output name=release-version::$(poetry version --short)"
- name: Print job inputs summary
run: |
echo "DRY_RUN=${{ env.DRY_RUN_STR }}"
echo "PYTHON_VERSION=${{ matrix.python-version }}"
echo "RELEASE_VERSION=${{ steps.get-meltano-version.outputs.release-version }}"
echo "COMMIT_SHA=${{ github.sha }}"
echo "DEBUG INFO: DRY_RUN is truthy=${{ env.DRY_RUN_STR == 'true' }}"
echo "DEBUG INFO: DRY_RUN is falsey=${{ env.DRY_RUN_STR == 'false' }}"
# These exist to show if 'dry-run' flag is set as intended and correctly parsed from inputs
- name: Print dry-run message (if applicable)
if: ${{ env.DRY_RUN_STR == 'true' }}
Expand All @@ -81,12 +70,12 @@ jobs:
run: |
# To save space, only publish the `latest` tag for each images to the GitHub registry
if [[ "${{ github.event.inputs.registry }}" != "ghcr.io" ]]; then
echo "meltano/meltano:v${{ steps.get-meltano-version.outputs.release-version }}-python${{ matrix.python-version }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "meltano/meltano:SHA-${{ github.sha }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "meltano/meltano:v${{ steps.get-meltano-version.outputs.release-version }}" >> tags
echo "v${{ steps.get-meltano-version.outputs.release-version }}-python${{ matrix.python-version }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "SHA-${{ github.sha }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "v${{ steps.get-meltano-version.outputs.release-version }}" >> tags
fi
echo "meltano/meltano:latest-python${{ matrix.python-version }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "meltano/meltano:latest" >> tags
echo "latest-python${{ matrix.python-version }}" >> tags
[[ "${{ matrix.is-default-python }}" == "true" ]] && echo "latest" >> tags
TAGS=$(cat tags)
TAGS="${TAGS//'%'/'%25'}"
Expand Down Expand Up @@ -114,11 +103,9 @@ jobs:
with:
push: ${{ env.DRY_RUN_STR == 'false' }}
token: ${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.assemble-tags.output }}
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
MELTANO_VERSION=${{ steps.get-meltano-version.outputs.release-version }}
tags: ${{ steps.assemble-tags.outputs.tags }}
registry: ${{ github.event.inputs.registry }}
username: ${{ steps.user-and-pass.outputs.username }}
password: ${{ steps.user-and-pass.outputs.password }}
python-version: ${{ matrix.python-version }}
meltano-version: ${{ steps.get-meltano-version.outputs.release-version }}

0 comments on commit 8e8e4a9

Please sign in to comment.