Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/actions/build-container/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ inputs:
required: false
default: ""
ghcr_username:
description: "Username for GHCR login"
description: "Username for GHCR login (github.actor when using the job's GITHUB_TOKEN)"
required: true
ghcr_password:
description: "Password for GHCR login"
description: "Password for GHCR login: the job's GITHUB_TOKEN with packages: write; the package must grant this repository Actions write access"
required: true
image_source:
description: "Repository URL for the org.opencontainers.image.source label, which links the package to that repository (defaults to the building repository). Builds of a private mirror pass the public repository so shared packages stay linked to it."
required: false
default: ""
git_sha:
description: "Git SHA to use for image tagging (defaults to github.sha)"
required: false
Expand All @@ -35,6 +39,9 @@ outputs:
artifact_name:
description: "The name of the uploaded artifact"
value: ${{ inputs.image_name }}:${{ env.GIT_SHA_SHORT }}
image_digest:
description: "The registry manifest digest of the pushed image (sha256:...); deploy by this, not by tag"
value: ${{ env.IMAGE_DIGEST }}

runs:
using: "composite"
Expand Down Expand Up @@ -68,13 +75,19 @@ runs:
[[ -n "$line" ]] && BUILD_ARGS_ARRAY+=("--build-arg" "$line")
done <<< "${{ inputs.build_args }}"

# The source label links the package to this repository on first push, so GHCR access follows the
# repository and nobody has to link packages by hand.
docker build \
"${BUILD_ARGS_ARRAY[@]}" \
--label "org.opencontainers.image.source=${{ inputs.image_source || format('{0}/{1}', github.server_url, github.repository) }}" \
--label "org.opencontainers.image.revision=${{ inputs.git_sha || github.sha }}" \
-f "$DOCKERFILE_PATH" \
-t ${{ inputs.image_name }}:${{ env.GIT_SHA_SHORT }} \
-t ${{ inputs.image_name }}:latest .
docker push ${{ inputs.image_name }}:${{ env.GIT_SHA_SHORT }}
docker push ${{ inputs.image_name }}:latest
IMAGE_DIGEST=$(docker inspect --format '{{index .RepoDigests 0}}' ${{ inputs.image_name }}:${{ env.GIT_SHA_SHORT }} | cut -d@ -f2)
echo "IMAGE_DIGEST=$IMAGE_DIGEST" >> $GITHUB_ENV
shell: bash

- name: Output image information
Expand All @@ -93,5 +106,6 @@ runs:
echo "- **Image:** \`${{ inputs.image_name }}:${{ env.GIT_SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** \`${{ env.GIT_SHA_SHORT }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** \`latest\`" >> $GITHUB_STEP_SUMMARY
echo "- **Digest:** \`${{ env.IMAGE_DIGEST }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Registry:** \`${{ inputs.image_name }}\`" >> $GITHUB_STEP_SUMMARY
shell: bash
18 changes: 11 additions & 7 deletions .github/workflows/build-versions.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "🔨 Build Version"
run-name: "Building version for ${{ inputs.ref || github.ref_name }}"
run-name: "Building version for ${{ inputs.ref || github.ref_name }}${{ inputs.request_id && format(' [{0}]', inputs.request_id) || '' }}"
on:
push:
workflow_dispatch:
Expand All @@ -11,6 +11,10 @@ on:
build_profile:
description: "The cargo build profile to use."
default: "release"
request_id:
description: "Service Manager request id; shown in the run name so the dispatch can be correlated (D37)."
required: false
default: ""

jobs:
setup:
Expand Down Expand Up @@ -142,8 +146,8 @@ jobs:
GIT_TAG=${{ needs.setup.outputs.git_tag }}
GIT_BRANCH=${{ needs.setup.outputs.git_branch }}
BUILD_DATE=${{ needs.setup.outputs.build_date }}
ghcr_username: ${{ vars.INFRA_GH_USER }}
ghcr_password: ${{ secrets.INFRA_GH_PAT }}
ghcr_username: ${{ github.actor }}
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
git_sha: ${{ needs.setup.outputs.git_sha }}

container-aptos-debugger:
Expand Down Expand Up @@ -180,8 +184,8 @@ jobs:
GIT_TAG=${{ needs.setup.outputs.git_tag }}
GIT_BRANCH=${{ needs.setup.outputs.git_branch }}
BUILD_DATE=${{ needs.setup.outputs.build_date }}
ghcr_username: ${{ vars.INFRA_GH_USER }}
ghcr_password: ${{ secrets.INFRA_GH_PAT }}
ghcr_username: ${{ github.actor }}
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
git_sha: ${{ needs.setup.outputs.git_sha }}

binaries-aptos-faucet-service:
Expand Down Expand Up @@ -242,8 +246,8 @@ jobs:
GIT_TAG=${{ needs.setup.outputs.git_tag }}
GIT_BRANCH=${{ needs.setup.outputs.git_branch }}
BUILD_DATE=${{ needs.setup.outputs.build_date }}
ghcr_username: ${{ vars.INFRA_GH_USER }}
ghcr_password: ${{ secrets.INFRA_GH_PAT }}
ghcr_username: ${{ github.actor }}
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
git_sha: ${{ needs.setup.outputs.git_sha }}

binaries-aptos-tools:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-builder-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ vars.INFRA_GH_USER || github.actor }}
password: ${{ secrets.INFRA_GH_PAT || secrets.GITHUB_TOKEN }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish images
shell: bash
Expand Down
Loading