-
Notifications
You must be signed in to change notification settings - Fork 12
Changed version and publish chart workflow #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
be078d4
e2d0d13
156f81e
7d189ae
77924a0
8ce0096
03de636
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,57 @@ | ||
| name: "Publish Chart" | ||
|
|
||
| on: | ||
| workflow_dispatch: # Allows manual triggering | ||
| pull_request: | ||
| paths: | ||
| - .github/workflows/publish_chart.yml | ||
| - chart/** | ||
| - chart/Chart.yaml | ||
| - .github/workflows/publish-chart.yml | ||
| push: | ||
| paths: | ||
| - .github/workflows/publish_chart.yml | ||
| - chart/** | ||
| - chart/Chart.yaml | ||
| - .github/workflows/publish-chart.yml | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| check-version-change: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| should_publish: ${{ steps.check-version.outputs.changed }} | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ github.head_ref || github.ref_name }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check if Chart Version Changed | ||
| id: check-version | ||
| if: github.event_name != 'workflow_dispatch' # Skip if manually triggered | ||
| run: | | ||
| if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then | ||
| PREVIOUS_VERSION=$(git show HEAD^:chart/Chart.yaml | grep 'version:' | awk '{print $2}') | ||
|
||
| CURRENT_VERSION=$(grep 'version:' chart/Chart.yaml | awk '{print $2}') | ||
|
|
||
| if [ "$PREVIOUS_VERSION" != "$CURRENT_VERSION" ]; then | ||
| echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Version didn't change ($CURRENT_VERSION)" | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| else | ||
| echo "Chart.yaml wasn't modified" | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Set Publish Flag for Manual Runs | ||
| if: github.event_name == 'workflow_dispatch' | ||
| run: echo "changed=true" >> $GITHUB_OUTPUT | ||
|
|
||
| publish-chart: | ||
| needs: check-version-change | ||
| if: needs.check-version-change.outputs.should_publish == 'true' || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Code | ||
|
|
@@ -38,4 +76,3 @@ jobs: | |
|
|
||
| - name: Push Packaged Chart to Registry | ||
| run: helm push ./tmp/* oci://${{ vars.REGISTRY_ADDR }}/library | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,12 +15,11 @@ build_push_image() { | |||||
| } | ||||||
|
|
||||||
| build_push_chart() { | ||||||
| version=$(cat VERSION) | ||||||
| version=$(yq -r '.version' chart/Chart.yaml) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The yq command is invoked with the -r flag but without the required sub-command (e|eval) that newer versions of mikefarah/yq expect; this exits with "unknown shorthand flag" and stops the build script (set -e). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using yq without the "eval" (or "e") sub-command fails with modern versions of mikefarah/yq (v4+): running
Suggested change
|
||||||
| helm package chart | ||||||
| helm push helm-charts-oci-proxy-$version.tgz oci://8gears.container-registry.com/library | ||||||
| } | ||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
|
|
||||||
| deploy() { | ||||||
| helm upgrade -i --namespace ocip-staging --create-namespace ocip-staging ./chart | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using HEAD^ assumes the previous commit exists; on the first commit of a branch or repository this command fails, causing the entire job to error out.