diff --git a/.github/workflows/change-app-version.yml b/.github/workflows/change-app-version.yml new file mode 100644 index 0000000..97c0b8d --- /dev/null +++ b/.github/workflows/change-app-version.yml @@ -0,0 +1,68 @@ +name: Change App-Version +on: + workflow_dispatch: + inputs: + app-version: + required: true + type: string + description: "change the version of the underlying application" + chart-location: + required: false + type: string + default: "." + description: "location of the helm chart" + chart-name: + required: true + type: string + description: "name of the helm chart" + workflow_call: + app-version: + required: true + type: string + description: "change the version of the underlying application" + chart-location: + required: false + type: string + default: "." + description: "location of the helm chart" + chart-name: + required: true + type: string + description: "name of the helm chart" + secrets: + GITHUB_TOKEN: + required: true + description: "github token for pushing changes" +jobs: + change-app-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: "Get Chart Version" + run: | + CHART_VERSION=$(grep '^version:' ${{ inputs.chart-name}}/Chart.yaml | awk '{print $2}') + CHART_PART=$(echo $CHART_VERSION | cut -d'-' -f1) + echo "CHART_VERSION=$CHART_PART" >> $GITHUB_ENV + working-directory: ${{ inputs.chart-location }} + - name: "Get new Chart Version" + run: | + APP_VERSION_NORMALIZED=$(echo "${{ inputs.app-version }}" | tr '.' '-') + NEW_VERSION="${CHART_VERSION}-release-${APP_VERSION_NORMALIZED}" + sed -i "s/^version:.*/version: $NEW_VERSION/" ${{ inputs.chart-name }}/Chart.yaml + sed -i "s/^appVersion:.*/appVersion: ${{ inputs.app-version }}/" ${{ inputs.chart-name }}/Chart.yaml + working-directory: ${{ inputs.chart-location }} + - name: "View chart-directory contents" + run: ls -al + working-directory: ${{ inputs.chart-location }} + - name: "View helm-chart.yaml" + run: cat Chart.yaml + working-directory: ${{ inputs.chart-location }}/${{ inputs.chart-name }} + - name: Commit and Push Changes + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email '67143880+MeepMr@users.noreply.github.com' + git commit -am "Updated ${{ inputs.chart-name }} application version to ${{ inputs.app-version }}" + git push \ No newline at end of file diff --git a/.github/workflows/publish-helm-chart.yml b/.github/workflows/publish-helm-chart.yml index b944d97..5038021 100644 --- a/.github/workflows/publish-helm-chart.yml +++ b/.github/workflows/publish-helm-chart.yml @@ -2,11 +2,6 @@ name: Publish Helm Chart with patched Application Version on: workflow_dispatch: inputs: - app-version: - required: false - type: string - description: "change the version of the underlying application" - default: "" chart-location: required: false type: string @@ -18,10 +13,6 @@ on: description: "name of the helm chart" workflow_call: inputs: - app-version: - required: true - type: string - description: "change the version of the underlying application" chart-location: required: false type: string @@ -46,30 +37,9 @@ jobs: uses: 1password/load-secrets-action/configure@v2 with: connect-host: https://op-connect.jk-dev.de - - name: "Get Chart Version" - if: inputs.app-version != '' - run: | - CHART_VERSION=$(grep '^version:' ${{ inputs.chart-name}}/Chart.yaml | awk '{print $2}') - CHART_PART=$(echo $CHART_VERSION | cut -d'-' -f1) - echo "CHART_VERSION=$CHART_PART" >> $GITHUB_ENV - working-directory: ${{ inputs.chart-location }} - - name: "Get new Chart Version" - if: inputs.app-version != '' - run: | - APP_VERSION_NORMALIZED=$(echo "${{ inputs.app-version }}" | tr '.' '-') - NEW_VERSION="${CHART_VERSION}-release-${APP_VERSION_NORMALIZED}" - sed -i "s/^version:.*/version: $NEW_VERSION/" ${{ inputs.chart-name }}/Chart.yaml - sed -i "s/^appVersion:.*/appVersion: ${{ inputs.app-version }}/" ${{ inputs.chart-name }}/Chart.yaml - working-directory: ${{ inputs.chart-location }} - name: "Package Helm Chart" run: helm package ${{ inputs.chart-name }} working-directory: ${{ inputs.chart-location }} - - name: "View directory contents" - run: ls -al - working-directory: ${{ inputs.chart-location }} - - name: "View helm-chart-meta contents" - run: cat Chart.yaml - working-directory: ${{ inputs.chart-location }}/${{ inputs.chart-name }} - name: "Load Helm Registry Credentials" id: load-jk-cr-creds uses: 1password/load-secrets-action@v2