Skip to content

Commit 9b57c7e

Browse files
committed
Add a set-vendir-channels-path-to-imgpkg-bundle action
1 parent cca3ec0 commit 9b57c7e

File tree

5 files changed

+68
-2
lines changed

5 files changed

+68
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file.
99
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1010
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1111

12+
## [Unreleased]
13+
14+
### Added
15+
16+
- Initial release of the set-vendir-channels-path-to-imgpkg-bundle action.
17+
1218
## [1.1.0] - 2024-11-10
1319

1420
### Added

next-image-tag-number/action.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ else
66
IMAGE_REPOSITORY_URL="$1"
77
fi
88
BEARER_TOKEN=$2
9-
INITIAL_NUMBER=${3:-1}
10-
TAG_PREFIX=${4:-"build-"}
9+
INITIAL_NUMBER=${3}
10+
TAG_PREFIX=${4}
1111

1212
if [ -n "$BEARER_TOKEN" ]; then
1313
AUTH_HEADER="-H \"Authorization: Bearer ${BEARER_TOKEN}\""
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:latest
2+
RUN apk add --update --no-cache --no-progress yq
3+
4+
# perl-utils: https://github.com/carvel-dev/ytt/issues/537
5+
RUN apk add --update --no-cache --no-progress bash perl-utils \
6+
&& wget -O- https://carvel.dev/install.sh | bash \
7+
&& apk del bash perl-utils
8+
9+
COPY action.sh /action.sh
10+
ENTRYPOINT ["/action.sh"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env sh
2+
3+
CHANNEL_NAME=$1
4+
IMGPKG_BUNDLE_IMAGE=$2
5+
BASE_PATH=$3
6+
7+
mkdir -p "$BASE_PATH"
8+
VENDIR_FILE="$BASE_PATH/vendir.yml"
9+
10+
if [ ! -f "$VENDIR_FILE" ]; then
11+
yq - > "$VENDIR_FILE" << 'EOF'
12+
---
13+
apiVersion: vendir.k14s.io/v1alpha1
14+
kind: Config
15+
EOF
16+
fi
17+
18+
yq -i "
19+
.directories = .directories // []
20+
| .directories = .directories + [{\"path\": \"channels\", \"contents\": []}]
21+
| .directories |= unique_by(.path)
22+
| with(
23+
.directories[] | select(.path == \"channels\");
24+
.contents = [{\"path\": \"$CHANNEL_NAME\", \"imgpkgBundle\": {\"image\": \"$IMGPKG_BUNDLE_IMAGE\"}}] + .contents
25+
| .contents |= unique_by(.path)
26+
)
27+
| .directories |= sort_by(.path == \"channels\" | not)
28+
" "$VENDIR_FILE"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Set Vendir Channels Path to Imgpkg Bundle
2+
description: Sets a vendir directory to a imgpkg bundle image.
3+
4+
inputs:
5+
channel_name:
6+
description: "The path under the channels directory to update."
7+
required: true
8+
imgpkg_bundle_image:
9+
description: "The imgpkg bundle image."
10+
required: true
11+
path:
12+
description: "The base directory path where vendir.yml is located."
13+
required: false
14+
default: "."
15+
16+
runs:
17+
using: docker
18+
image: Dockerfile
19+
args:
20+
- ${{ inputs.channel_name }}
21+
- ${{ inputs.imgpkg_bundle_image }}
22+
- ${{ inputs.path }}

0 commit comments

Comments
 (0)