Skip to content

Commit 04ec849

Browse files
committed
feat(agentless): only push agent containers on merges to main
1 parent e797d1d commit 04ec849

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.github/workflows/agentless-container.yaml

Lines changed: 10 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
@@ -57,7 +63,10 @@ jobs:
5763
done
5864
TAGS=$(echo $TAGS | tr '[:upper:]' '[:lower:]')
5965
60-
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 [ -z ${GITHUB_BASE_REF+x} ]; 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
6170
6271
cat metadata.json
6372
echo "digest=$(cat metadata.json | jq -r .\"containerimage.digest\")" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)