Skip to content

Commit

Permalink
save digest artifacts and parse image name
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreat committed Nov 13, 2024
1 parent 36d0f4a commit fea4658
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
16 changes: 9 additions & 7 deletions docker-merge-digests/action.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Mobilecoin Docker
description: Standardized docker build and publish actions
name: Docker Merge Digest
description: This action takes a list of docker image digests and merges them into a manifest that we can tag and push to a registry. This is useful for creating a manifest list for multi-arch images. Digests are stored as an empty file attached as artifacts to the build by previous steps.

inputs:
digest_artifact_prefix:
description: Prefix for the artifact names to restore
required: false
default: ""
flavor:
description: New line separated list of docker meta flavor options
required: false
Expand Down Expand Up @@ -35,11 +31,17 @@ outputs:
runs:
using: composite
steps:
- name: Parse Image Name
shell: bash
run: |
IMAGE_NAME=${{ inputs.images }}
echo "IMAGE_NAME=${IMAGE_NAME#*/}" >> "${GITHUB_ENV}"
- name: Download digests
uses: mobilecoinofficial/gh-actions/download-artifact@v0
with:
path: /tmp/digests
pattern: ${{ inputs.digest_artifact_prefix }}*
pattern: digests-${{ env.IMAGE_NAME }}*
merge-multiple: true

- name: Set up Docker Buildx
Expand Down
28 changes: 28 additions & 0 deletions docker/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ inputs:
description: override the image output methods https://docs.docker.com/build/exporters/
required: false
default: ""
save_digest:
description: save the docker image digest to an artifact
required: false
default: "false"

outputs:
tags:
Expand Down Expand Up @@ -108,3 +112,27 @@ runs:
tags: ${{ inputs.outputs == '' && steps.docker_meta.outputs.tags || '' }}
target: ${{ inputs.target }}
outputs: ${{ inputs.outputs }}

- name: Parse Image Name
if: inputs.save_digest == 'true'
shell: bash
run: |
IMAGE_NAME=${{ inputs.images }}
echo "IMAGE_NAME=${IMAGE_NAME#*/}" >> "${GITHUB_ENV}"
- name: Export Digest
if: inputs.save_digest == 'true'
shell: bash
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload Digests
if: inputs.save_digest == 'true'
uses: mobilecoinofficial/gh-actions/upload-artifact@v0
with:
name: digests-${{ env.IMAGE_NAME }}-${{ runner.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

0 comments on commit fea4658

Please sign in to comment.