@@ -925,7 +925,6 @@ jobs:
925925 runs-on : ubuntu-24.04-arm
926926 permissions :
927927 contents : read
928- id-token : write
929928 actions : read
930929 steps :
931930 - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
@@ -950,25 +949,43 @@ jobs:
950949 name : image-${{ needs.build-id.outputs.value }}-lambdaImage
951950 path : image.tar.gz
952951 if-no-files-found : error
953- - name : fetch prebuilt image
954- if : needs.build-id.outputs.image_lambda != ''
952+ lambda-image-push :
953+ name : push lambda image to ECR
954+ needs : [build-id, lambda-image]
955+ # Separate job: `environment` is job-level, and lambda-image also runs untagged.
956+ if : >-
957+ !cancelled() && needs.lambda-image.result == 'success' &&
958+ startsWith(github.ref, 'refs/tags/') && inputs.dry_run != true
959+ runs-on : ubuntu-24.04-arm
960+ environment : biz
961+ permissions :
962+ contents : read
963+ id-token : write
964+ actions : read
965+ steps :
966+ - uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
967+ - name : fetch image
955968 env :
956969 GH_TOKEN : ${{ github.token }}
957970 ARTIFACT_ID : ${{ needs.build-id.outputs.image_lambda }}
971+ RUN_ARTIFACT : image-${{ needs.build-id.outputs.value }}-lambdaImage
958972 run : |
959- gh api "/repos/$GITHUB_REPOSITORY/actions/artifacts/$ARTIFACT_ID/zip" > i.zip
973+ id="$ARTIFACT_ID"
974+ if [ -z "$id" ]; then
975+ id="$(gh api --paginate "/repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts" \
976+ --jq ".artifacts[] | select(.name==\"$RUN_ARTIFACT\") | .id" | head -1)"
977+ fi
978+ test -n "$id" || { echo "::error::no lambda image artifact to push" >&2; exit 1; }
979+ gh api "/repos/$GITHUB_REPOSITORY/actions/artifacts/$id/zip" > i.zip
960980 unzip -q i.zip
961- # The nix legs upload the tarball as <package>.tar.gz; normalize.
962981 [ -f lambdaImage.tar.gz ] && mv lambdaImage.tar.gz image.tar.gz
963- test -f image.tar.gz || { echo "no image tarball in artifact $ARTIFACT_ID " >&2; ls -l >&2; exit 1; }
982+ test -f image.tar.gz || { echo "no image tarball in artifact $id " >&2; ls -l >&2; exit 1; }
964983 {
965984 echo "REF=${GITHUB_REF_NAME:-dev}"
966985 echo "IMG_SIZE=$(ls -lh image.tar.gz | awk '{print $5}')"
967986 } >> "$GITHUB_ENV"
968- - if : needs.build-id.outputs.image_lambda != '' && startsWith(github.ref, 'refs/tags/')
969- uses : DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25
987+ - uses : DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25
970988 - name : assume ECR push role (OIDC)
971- if : startsWith(github.ref, 'refs/tags/') && inputs.dry_run != true
972989 run : |
973990 role="${{ vars.ABGEN_LAMBDA_ECR_ROLE_ARN }}"
974991 region="${{ vars.ABGEN_LAMBDA_AWS_REGION }}"
@@ -991,14 +1008,13 @@ jobs:
9911008 echo "AWS_REGION=${region}"
9921009 } >> "$GITHUB_ENV"
9931010 - name : push to ECR
994- if : startsWith(github.ref, 'refs/tags/') && inputs.dry_run != true
9951011 run : |
9961012 repo="${{ vars.ABGEN_LAMBDA_ECR_REPOSITORY }}"
9971013 registry="${repo%%/*}"
9981014 password="$(aws ecr get-login-password)"
9991015 conf="$(mktemp)"
10001016 echo 'unqualified-search-registries = []' > "$conf"
1001- for tag in "${REF}" latest ; do
1017+ for tag in "${REF}"; do
10021018 nix run --inputs-from . nixpkgs#skopeo -- \
10031019 --registries-conf "$conf" --insecure-policy copy \
10041020 --dest-creds "AWS:${password}" \
@@ -1014,7 +1030,7 @@ jobs:
10141030 echo ""
10151031 echo "| | |"
10161032 echo "|---|---|"
1017- echo "| image | \`${repo}:${REF}\` (and \`:latest\`) |"
1033+ echo "| image | \`${repo}:${REF}\` |"
10181034 echo "| digest | \`${digest}\` |"
10191035 echo "| size | ${IMG_SIZE} compressed, no base OS |"
10201036 echo "| arch | arm64 (Graviton Lambda) |"
0 commit comments