debian-forge-composer/tools/ci-build-worker-packer.sh
Sanne Raymaekers c7aad1b17d tools/app-sre-build-worker-packer: split out the CI script
To add the fedora workers built from AppSRE's infrastructure, we need a
combination that wasn't possible with the current matrix based on the CI
environment (jenkins vs gitlab).
2024-01-23 00:18:51 +01:00

34 lines
991 B
Bash
Executable file

#!/bin/bash
# AppSRE runs this script to build an ami and share it with an account
set -exv
COMMIT_SHA=$(git rev-parse HEAD)
COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
SKIP_CREATE_AMI=false
BUILD_RPMS=false
# Use prebuilt rpms on CI
SKIP_TAGS="rpmcopy,subscribe"
if [ -n "$CI_COMMIT_SHA" ]; then
COMMIT_SHA="$CI_COMMIT_SHA"
fi
if [ -n "$CI_COMMIT_BRANCH" ]; then
COMMIT_BRANCH="$CI_COMMIT_BRANCH"
fi
# skip creating AMIs on PRs to save a ton of resources
if [[ $COMMIT_BRANCH == PR-* ]]; then
SKIP_CREATE_AMI=true
fi
if [ -n "$CI_COMMIT_BRANCH" ] && [ "$CI_COMMIT_BRANCH" == "main" ]; then
# Schutzbot on main: build all except rhel
PACKER_ONLY_EXCEPT=--except=amazon-ebs.rhel-9-x86_64,amazon-ebs.rhel-9-aarch64
else
# Schutzbot but not main, build everything (use dummy except)
PACKER_ONLY_EXCEPT=--except=amazon-ebs.dummy
fi
export COMMIT_SHA COMMIT_BRANCH SKIP_CREATE_AMI BUILD_RPMS SKIP_TAGS PACKER_ONLY_EXCEPT
tools/appsre-build-worker-packer.sh