Skip to content

Commit f72db66

Browse files
Merge pull request #13 from projectcapsule/feat/versioned-actions
feat: versioned workflow
2 parents e738a3b + 0bd90b8 commit f72db66

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

.github/workflows/headlamp.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,25 +123,43 @@ jobs:
123123
124124
cd "$WORKDIR"
125125
126-
test -f artifacthub-pkg.yml || {
127-
echo "❌ artifacthub-pkg.yml not found on artifacthub branch"
126+
TEMPLATE_PKG=""
127+
if [ -f artifacthub-pkg.template.yml ]; then
128+
TEMPLATE_PKG="artifacthub-pkg.template.yml"
129+
fi
130+
131+
if [ -z "$TEMPLATE_PKG" ] && [ -f artifacthub-pkg.yml ]; then
132+
TEMPLATE_PKG="artifacthub-pkg.yml"
133+
fi
134+
135+
if [ -z "$TEMPLATE_PKG" ]; then
136+
TEMPLATE_PKG="$(find . -mindepth 2 -maxdepth 2 -name artifacthub-pkg.yml | sort -V | tail -n1)"
137+
fi
138+
139+
test -n "$TEMPLATE_PKG" || {
140+
echo "❌ No artifacthub-pkg.yml template found on artifacthub branch"
128141
exit 1
129142
}
130143
131-
yq -i '.version = strenv(VERSION)' artifacthub-pkg.yml
132-
yq -i '.createdAt = strenv(CREATED_AT)' artifacthub-pkg.yml
133-
yq -i '.annotations."headlamp/plugin/archive-url" = strenv(ARCHIVE_URL)' artifacthub-pkg.yml
134-
yq -i '.annotations."headlamp/plugin/archive-checksum" = "sha256:" + strenv(CHECKSUM)' artifacthub-pkg.yml
144+
mkdir -p "$VERSION"
145+
cp "$TEMPLATE_PKG" "$VERSION/artifacthub-pkg.yml"
146+
147+
yq -i '.version = strenv(VERSION)' "$VERSION/artifacthub-pkg.yml"
148+
yq -i '.createdAt = strenv(CREATED_AT)' "$VERSION/artifacthub-pkg.yml"
149+
yq -i '.annotations."headlamp/plugin/archive-url" = strenv(ARCHIVE_URL)' "$VERSION/artifacthub-pkg.yml"
150+
yq -i '.annotations."headlamp/plugin/archive-checksum" = "sha256:" + strenv(CHECKSUM)' "$VERSION/artifacthub-pkg.yml"
151+
rm -f artifacthub-pkg.yml
135152
136-
echo "✅ artifacthub-pkg.yml updated:"
153+
echo "✅ Artifact Hub metadata published:"
137154
echo " version: $VERSION"
155+
echo " path: $VERSION/artifacthub-pkg.yml"
138156
echo " archive-url: $ARCHIVE_URL"
139157
echo " checksum: sha256:$CHECKSUM"
140158
141159
git config user.name "github-actions[bot]"
142160
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
143161
144-
git add artifacthub-pkg.yml
162+
git add -A
145163
git commit -m "chore(release): publish Artifact Hub metadata for $TAG" || echo "No changes to commit"
146164
git push origin artifacthub
147165
@@ -167,4 +185,4 @@ jobs:
167185
with:
168186
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
169187
subject-digest: ${{ steps.docker-build.outputs.digest }}
170-
push-to-registry: true
188+
push-to-registry: true

0 commit comments

Comments
 (0)