Skip to content

Commit

Permalink
fix: avoid exiting on oras discover
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Ortega <[email protected]>
  • Loading branch information
M0NsTeRRR committed Dec 19, 2024
1 parent 56b5c67 commit b004da7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ jobs:
chart=$(basename "$chart_path")
# get current version
current_version=$(grep '^version:' "$chart_path/Chart.yaml" | awk '{print $2}')
# get current release version
# try to get current release version
set +e
oras discover ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}:${current_version}
set -e
if [ "$?" -eq 1 ]; then
if [ $? -ne 0 ]; then
helm dependency build "$chart_path"
helm package "$chart_path" --destination ./.cr-release-packages
else
Expand Down Expand Up @@ -89,6 +91,12 @@ jobs:
with:
fetch-depth: 0

- name: Install helm
uses: azure/setup-helm@v4

- name: Install Oras
uses: oras-project/setup-oras@v1

- name: Install Cosign
uses: sigstore/cosign-installer@v3

Expand All @@ -98,15 +106,22 @@ jobs:
name: artifacts
path: .cr-release-packages/

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push charts to GHCR
env:
COSIGN_YES: true
run: |
for chart_path in `find .cr-release-packages -name '*.tgz' -print`; do
# push chart to OCI
helm push ${chart_path} oci://ghcr.io/${GITHUB_REPOSITORY@L} |& tee helm-push-output.log
# push chart to OCI
chart_release_file=$(basename "$chart_path")
chart=${chart_release_file%-*}
helm push ${chart_path} oci://ghcr.io/${GITHUB_REPOSITORY@L} |& tee helm-push-output.log
chart_digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log)
# sign chart
cosign sign "ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}@${chart_digest}"
Expand Down

0 comments on commit b004da7

Please sign in to comment.