fix: use shell substitutions in Tekton tasks
This commit is contained in:
1 parent
52233a7a78
commit
5422fef4fb
1 file changed
+17
-17
@@ -25,10 +25,10 @@ spec:
|
|||||||
set -eu
|
set -eu
|
||||||
SOURCE_DIR="$(workspaces.source.path)"
|
SOURCE_DIR="$(workspaces.source.path)"
|
||||||
REVISION="$(params.revision)"
|
REVISION="$(params.revision)"
|
||||||
AUTH_HOME="$$(mktemp -d)"
|
AUTH_HOME="$(mktemp -d)"
|
||||||
trap 'rm -rf "$AUTH_HOME"' EXIT
|
trap 'rm -rf "$AUTH_HOME"' EXIT
|
||||||
USERNAME="$$(cat "$(workspaces.credentials.path)/username")"
|
USERNAME="$(cat "$(workspaces.credentials.path)/username")"
|
||||||
PASSWORD="$$(cat "$(workspaces.credentials.path)/password")"
|
PASSWORD="$(cat "$(workspaces.credentials.path)/password")"
|
||||||
cat >"$AUTH_HOME/.netrc" <<EOF
|
cat >"$AUTH_HOME/.netrc" <<EOF
|
||||||
machine git.dahyeon.us
|
machine git.dahyeon.us
|
||||||
login $USERNAME
|
login $USERNAME
|
||||||
@@ -39,7 +39,7 @@ spec:
|
|||||||
find "$SOURCE_DIR" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
|
find "$SOURCE_DIR" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
|
||||||
git clone --quiet --no-tags "$REPO_URL" "$SOURCE_DIR"
|
git clone --quiet --no-tags "$REPO_URL" "$SOURCE_DIR"
|
||||||
git -C "$SOURCE_DIR" checkout --quiet --detach "$REVISION"
|
git -C "$SOURCE_DIR" checkout --quiet --detach "$REVISION"
|
||||||
ACTUAL_REVISION="$$(git -C "$SOURCE_DIR" rev-parse HEAD)"
|
ACTUAL_REVISION="$(git -C "$SOURCE_DIR" rev-parse HEAD)"
|
||||||
if [ "$ACTUAL_REVISION" != "$REVISION" ]; then
|
if [ "$ACTUAL_REVISION" != "$REVISION" ]; then
|
||||||
echo "Expected revision $REVISION, got $ACTUAL_REVISION" >&2
|
echo "Expected revision $REVISION, got $ACTUAL_REVISION" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -173,7 +173,7 @@ spec:
|
|||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
DIGEST="$$(yq -r '."containerimage.digest"' "$(results.image-digest.path)")"
|
DIGEST="$(yq -r '."containerimage.digest"' "$(results.image-digest.path)")"
|
||||||
if [ -z "$DIGEST" ] || [ "$DIGEST" = "null" ]; then
|
if [ -z "$DIGEST" ] || [ "$DIGEST" = "null" ]; then
|
||||||
echo "BuildKit did not return an image digest" >&2
|
echo "BuildKit did not return an image digest" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -205,10 +205,10 @@ spec:
|
|||||||
script: |
|
script: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
AUTH_HOME="$$(mktemp -d)"
|
AUTH_HOME="$(mktemp -d)"
|
||||||
trap 'rm -rf "$AUTH_HOME"' EXIT
|
trap 'rm -rf "$AUTH_HOME"' EXIT
|
||||||
USERNAME="$$(cat "$(workspaces.credentials.path)/username")"
|
USERNAME="$(cat "$(workspaces.credentials.path)/username")"
|
||||||
PASSWORD="$$(cat "$(workspaces.credentials.path)/password")"
|
PASSWORD="$(cat "$(workspaces.credentials.path)/password")"
|
||||||
cat >"$AUTH_HOME/.netrc" <<EOF
|
cat >"$AUTH_HOME/.netrc" <<EOF
|
||||||
machine git.dahyeon.us
|
machine git.dahyeon.us
|
||||||
login $USERNAME
|
login $USERNAME
|
||||||
@@ -216,7 +216,7 @@ spec:
|
|||||||
EOF
|
EOF
|
||||||
chmod 0600 "$AUTH_HOME/.netrc"
|
chmod 0600 "$AUTH_HOME/.netrc"
|
||||||
export HOME="$AUTH_HOME"
|
export HOME="$AUTH_HOME"
|
||||||
REMOTE_REVISION="$$(git ls-remote "$REPO_URL" refs/heads/main | awk 'NR == 1 {print $1}')"
|
REMOTE_REVISION="$(git ls-remote "$REPO_URL" refs/heads/main | awk 'NR == 1 {print $1}')"
|
||||||
if [ "$REMOTE_REVISION" != "$(params.revision)" ]; then
|
if [ "$REMOTE_REVISION" != "$(params.revision)" ]; then
|
||||||
echo "Revision $(params.revision) was superseded by $REMOTE_REVISION" >&2
|
echo "Revision $(params.revision) was superseded by $REMOTE_REVISION" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -296,10 +296,10 @@ spec:
|
|||||||
set -eu
|
set -eu
|
||||||
SOURCE_DIR="$(workspaces.source.path)"
|
SOURCE_DIR="$(workspaces.source.path)"
|
||||||
STATE_DIR="$SOURCE_DIR/.gitops"
|
STATE_DIR="$SOURCE_DIR/.gitops"
|
||||||
AUTH_HOME="$$(mktemp -d)"
|
AUTH_HOME="$(mktemp -d)"
|
||||||
trap 'rm -rf "$AUTH_HOME"' EXIT
|
trap 'rm -rf "$AUTH_HOME"' EXIT
|
||||||
USERNAME="$$(cat "$(workspaces.credentials.path)/username")"
|
USERNAME="$(cat "$(workspaces.credentials.path)/username")"
|
||||||
PASSWORD="$$(cat "$(workspaces.credentials.path)/password")"
|
PASSWORD="$(cat "$(workspaces.credentials.path)/password")"
|
||||||
cat >"$AUTH_HOME/.netrc" <<EOF
|
cat >"$AUTH_HOME/.netrc" <<EOF
|
||||||
machine git.dahyeon.us
|
machine git.dahyeon.us
|
||||||
login $USERNAME
|
login $USERNAME
|
||||||
@@ -323,7 +323,7 @@ spec:
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
MANIFEST="$(workspaces.source.path)/.gitops/apps/lolympus-tournament-support/overlays/staging/kustomization.yaml"
|
MANIFEST="$(workspaces.source.path)/.gitops/apps/lolympus-tournament-support/overlays/staging/kustomization.yaml"
|
||||||
MATCHES="$$(yq '[.images[] | select(.name == strenv(IMAGE_NAME))] | length' "$MANIFEST")"
|
MATCHES="$(yq '[.images[] | select(.name == strenv(IMAGE_NAME))] | length' "$MANIFEST")"
|
||||||
if [ "$MATCHES" != "1" ]; then
|
if [ "$MATCHES" != "1" ]; then
|
||||||
echo "Expected one image entry for $IMAGE_NAME, found $MATCHES" >&2
|
echo "Expected one image entry for $IMAGE_NAME, found $MATCHES" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -340,10 +340,10 @@ spec:
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
STATE_DIR="$(workspaces.source.path)/.gitops"
|
STATE_DIR="$(workspaces.source.path)/.gitops"
|
||||||
AUTH_HOME="$$(mktemp -d)"
|
AUTH_HOME="$(mktemp -d)"
|
||||||
trap 'rm -rf "$AUTH_HOME"' EXIT
|
trap 'rm -rf "$AUTH_HOME"' EXIT
|
||||||
USERNAME="$$(cat "$(workspaces.credentials.path)/username")"
|
USERNAME="$(cat "$(workspaces.credentials.path)/username")"
|
||||||
PASSWORD="$$(cat "$(workspaces.credentials.path)/password")"
|
PASSWORD="$(cat "$(workspaces.credentials.path)/password")"
|
||||||
cat >"$AUTH_HOME/.netrc" <<EOF
|
cat >"$AUTH_HOME/.netrc" <<EOF
|
||||||
machine git.dahyeon.us
|
machine git.dahyeon.us
|
||||||
login $USERNAME
|
login $USERNAME
|
||||||
@@ -357,7 +357,7 @@ spec:
|
|||||||
git -C "$STATE_DIR" rev-parse HEAD >"$(results.gitops-commit.path)"
|
git -C "$STATE_DIR" rev-parse HEAD >"$(results.gitops-commit.path)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
REMOTE_REVISION="$$(git ls-remote "$SOURCE_REPO_URL" refs/heads/main | awk 'NR == 1 {print $1}')"
|
REMOTE_REVISION="$(git ls-remote "$SOURCE_REPO_URL" refs/heads/main | awk 'NR == 1 {print $1}')"
|
||||||
if [ "$REMOTE_REVISION" != "$(params.revision)" ]; then
|
if [ "$REMOTE_REVISION" != "$(params.revision)" ]; then
|
||||||
echo "Revision $(params.revision) was superseded by $REMOTE_REVISION" >&2
|
echo "Revision $(params.revision) was superseded by $REMOTE_REVISION" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in new issue
Block a user