This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/pkg/universe.dagger.io/x/david@rawkode.dev/pulumi/up.sh
David Flanagan 88748d3563
fix: appease the linter
Signed-off-by: David Flanagan <david@rawkode.dev>
2022-04-01 21:03:51 +01:00

41 lines
1.0 KiB
Bash

#!/usr/bin/env bash
set -xeo pipefail
if test -v PULUMI_CONFIG_PASSPHRASE || test -v PULUMI_CONFIG_PASSPHRASE_FILE; then
echo "PULUMI_CONFIG_PASSPHRASE is set, using a local login"
pulumi login --local
fi
# Using Pulumi SaaS
# We need to check for an existing stack with the name
# If it exists, refresh the config
# If it doesn't, create the stack
if test -v PULUMI_ACCESS_TOKEN; then
if (pulumi stack ls | grep -e "^${STACK_NAME}"); then
echo "Stack exists, let's refresh"
pulumi stack select "${PULUMI_STACK}"
# Could be first deployment, so let's not worry about this failing
pulumi config refresh --force || true
else
echo "Stack does not exist, let's create"
pulumi stack init "${PULUMI_STACK}"
fi
else
# Not using Pulumi SaaS, relying on local stack files
if test -v PULUMI_STACK_CREATE && test ! -f "Pulumi.${PULUMI_STACK}.yaml"; then
pulumi stack init "${PULUMI_STACK}"
fi
fi
case "$PULUMI_RUNTIME" in
nodejs)
npm install
;;
*)
echo -n "unknown"
;;
esac
pulumi up --stack "${PULUMI_STACK}" --yes