Upgrade to v4.0.1 #95
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Helm | |
| on: | |
| issues: | |
| types: [opened] | |
| jobs: | |
| check: | |
| name: Check for Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| release_found: ${{ steps.compare_versions.outputs.release_found }} | |
| release_tag: ${{ steps.get_tags.outputs.tag }} | |
| issue_number: ${{ steps.get_issue.outputs.issue_number }} | |
| issue_title: ${{ steps.get_issue.outputs.issue_title }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get issue that caused the workflow to run | |
| id: get_issue | |
| run: | | |
| issue_number=$(jq --raw-output .issue.number "$GITHUB_EVENT_PATH") | |
| issue_title=$(jq --raw-output .issue.title "$GITHUB_EVENT_PATH") | |
| echo "issue_number: $issue_number" | |
| echo "issue_title: $issue_title" | |
| echo "issue_number=${issue_number}" >> $GITHUB_OUTPUT | |
| echo "issue_title=${issue_title}" >> $GITHUB_OUTPUT | |
| - name: Get Helm tags | |
| id: get_tags | |
| run: | | |
| LATEST_TAG=$(curl --silent --fail https://api.github.com/repos/helm/helm/tags | jq -r .[0].name) | |
| echo "Latest tag: ${LATEST_TAG}" | |
| echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_ENV | |
| echo "tag=${LATEST_TAG}" >> $GITHUB_OUTPUT | |
| - name: Compare versions | |
| id: compare_versions | |
| run: | | |
| if grep -q "ENV VERSION ${{ env.LATEST_TAG }}$" Dockerfile | |
| then | |
| echo "Not a new version, skipping..." | |
| echo "release_found=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Found a new release: $LATEST_TAG" | |
| echo "release_found=true" >> $GITHUB_OUTPUT | |
| fi | |
| update: | |
| name: Update Dockerfile | |
| needs: check | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.check.outputs.release_found == 'true' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: Update | |
| run: | | |
| sed -i "3s/.*/ENV VERSION ${{ needs.check.outputs.release_tag }}/" Dockerfile | |
| - name: Commit and Push - Full version tag | |
| run: | | |
| set -x | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| commit_message="Update version to ${{ needs.check.outputs.release_tag }}" | |
| # check if the issue title contains the version number we're upgrading | |
| if [[ "${{ needs.check.outputs.issue_title }}" == *"${{ needs.check.outputs.release_tag }}"* ]]; then | |
| # if so, close it via commit message | |
| commit_message="${commit_message}; fix #${{ needs.check.outputs.issue_number }}" | |
| fi | |
| git diff | |
| git commit -am "$commit_message" | |
| git tag ${{ needs.check.outputs.release_tag }} | |
| # must push with a PAT in order to trigger downstream github actions | |
| - name: Push changes | |
| run: | | |
| git push | |
| git push origin ${{ needs.check.outputs.release_tag }} |