packer: don't save the AMIs on PRs
This should save us a ton of resources as we don't use AMIs from PRs. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
ad15179faf
commit
72de1b3bbe
3 changed files with 15 additions and 0 deletions
|
|
@ -18,6 +18,12 @@ variable "region" {
|
|||
# Automatically set by environment variables
|
||||
variable "composer_commit" { type = string }
|
||||
|
||||
# Controls whether AMIs should be created. If you just need to test whether the image can be built, leave it as true
|
||||
variable "skip_create_ami" {
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
# The name of the resulting AMI and the underlying EBS snapshot
|
||||
variable "image_name" { type = string }
|
||||
# A list of users to share the AMI with
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ source "amazon-ebs" "image_builder" {
|
|||
# Network configuration for the instance building our image.
|
||||
associate_public_ip_address = true
|
||||
ssh_interface = "public_ip"
|
||||
|
||||
skip_create_ami=var.skip_create_ami
|
||||
}
|
||||
|
||||
build {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ set -exv
|
|||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
ON_JENKINS=true
|
||||
SKIP_CREATE_AMI=false
|
||||
|
||||
# Use gitlab CI variables if available
|
||||
if [ -n "$CI_COMMIT_SHA" ]; then
|
||||
|
|
@ -23,6 +24,11 @@ if [ "$ON_JENKINS" = false ]; then
|
|||
sudo dnf install -y podman jq
|
||||
fi
|
||||
|
||||
# skip creating AMIs on PRs to save a ton of resources
|
||||
if [[ $COMMIT_BRANCH == PR-* ]]; then
|
||||
SKIP_CREATE_AMI=true
|
||||
fi
|
||||
|
||||
# decide whether podman or docker should be used
|
||||
if which podman 2>/dev/null >&2; then
|
||||
CONTAINER_RUNTIME=podman
|
||||
|
|
@ -202,4 +208,5 @@ $CONTAINER_RUNTIME run --rm \
|
|||
-e PKR_VAR_image_name="osbuild-composer-worker-$COMMIT_BRANCH-$COMMIT_SHA" \
|
||||
-e PKR_VAR_composer_commit="$COMMIT_SHA" \
|
||||
-e PKR_VAR_ansible_skip_tags="$SKIP_TAGS" \
|
||||
-e PKR_VAR_skip_create_ami="$SKIP_CREATE_AMI" \
|
||||
"packer:$COMMIT_SHA" /osbuild-composer/worker-packer.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue