Skip to content

Commit 5d8c2df

Browse files
committed
fix(agentless): force lowercase for agentless tags, build but don't push on prs (#14)
* fix(agentless): force lowercase for agentless tags * feat(agentless): only push agent containers on merges to main
1 parent e5e8279 commit 5d8c2df

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/agentless-container.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Build and push agentless container image
22

33
# Configures this workflow to run every time a tag is created
44
on:
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- containers/agentless/**
10+
- .github/workflows/agentless-container.yaml
511
push:
612
branches:
713
- main
@@ -55,8 +61,12 @@ jobs:
5561
for version in $TEST_VERSIONS; do
5662
TAGS+="-t ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agentless:$version "
5763
done
64+
TAGS=$(echo $TAGS | tr '[:upper:]' '[:lower:]')
5865
59-
docker buildx build --push --platform linux/amd64,linux/arm64 $TAGS --metadata-file=metadata.json -f ../containers/agentless/Dockerfile ../containers/agentless
66+
# GITHUB_BASE_REF is only set when the action source event is a pull request.
67+
# in that case don't push.
68+
export PUSH=$(if [ ${{ github.event.action }} != 'pull_request' ]; then echo "--push"; else echo ""; fi)
69+
docker buildx build $PUSH --platform linux/amd64,linux/arm64 $TAGS --metadata-file=metadata.json -f ../containers/agentless/Dockerfile ../containers/agentless
6070
6171
cat metadata.json
6272
echo "digest=$(cat metadata.json | jq -r .\"containerimage.digest\")" >> $GITHUB_OUTPUT
@@ -65,6 +75,7 @@ jobs:
6575
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
6676
- name: Generate artifact attestation
6777
uses: actions/attest-build-provenance@v2
78+
if: ${{ github.event.action != 'pull_request' }}
6879
with:
6980
subject-name: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agentless
7081
subject-digest: ${{ steps.build.outputs.digest }}

0 commit comments

Comments
 (0)