Update workflow so it works with the new version of GA's (#735) #289
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: Publish Octopus Deploy Chart | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - release/octopus-deploy/v* | |
| workflow_dispatch: | |
| jobs: | |
| paths_filter: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| result: ${{ steps.filter.outputs.octopus-deploy }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: dorny/paths-filter@v4 | |
| id: filter | |
| with: | |
| filters: | | |
| octopus-deploy: | |
| - charts/octopus-deploy/** | |
| - .github/workflows/octopus-publish-chart.yml | |
| test: | |
| needs: paths_filter | |
| if: needs.paths_filter.outputs.result == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Install Helm | |
| uses: azure/setup-helm@v5.0.1 | |
| with: | |
| version: v3.19.4 | |
| - name: Run Helm unit tests | |
| run: | | |
| helm plugin install https://github.com/helm-unittest/helm-unittest.git | |
| helm unittest charts/octopus-deploy | |
| - name: Login to GitHub container registry | |
| run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{github.actor}} --password-stdin | |
| - name: Login to Docker Hub | |
| run: echo ${{ secrets.DOCKERHUB_TOKEN }} | helm registry login registry-1.docker.io -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
| - name: Parse Chart config | |
| uses: pietrobolcato/action-read-yaml@1.1.0 | |
| id: read_chart_yaml | |
| with: | |
| config: ${{ github.workspace }}/charts/octopus-deploy/Chart.yaml | |
| - name: Get branch names | |
| id: branch_names | |
| uses: OctopusDeploy/util-actions/current-branch-name@current-branch-name.0.1.0 | |
| - name: Generate chart version | |
| id: version | |
| shell: bash | |
| run: | | |
| chart_version="${{ steps.read_chart_yaml.outputs.version }}" | |
| pre_release="" | |
| if [[ "${{steps.branch_names.outputs.branch_name}}" != "main" ]] | |
| then | |
| # underscores in branches make for illegal version-string, replace with "-" | |
| cleansed_branch=`echo ${{steps.branch_names.outputs.branch_name}} | sed s/_/-/g` | |
| pre_release="-${cleansed_branch}-$(date +'%Y%m%d%H%M%S')" | |
| fi | |
| full_version="$chart_version$pre_release" | |
| echo "CHART_VERSION=$full_version" >> $GITHUB_OUTPUT | |
| echo "PACKAGE_NAME=octopusdeploy-helm-$full_version.tgz" >> $GITHUB_OUTPUT | |
| - name: Package Chart | |
| run: helm package --version '${{ steps.version.outputs.CHART_VERSION }}' 'charts/octopus-deploy' | |
| - uses: actions/upload-artifact@v7 | |
| name: Upload packaged chart | |
| with: | |
| name: '${{ steps.version.outputs.PACKAGE_NAME }}' | |
| path: '${{ github.workspace }}/octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz' | |
| # Only push the chart for real if it's a branch build OR it's the versioning PR | |
| - name: Push Chart to GHCR | |
| if: ${{ github.ref != 'refs/heads/main' || (github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, 'Version Charts')) }} | |
| run: helm push "octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz" oci://ghcr.io/octopusdeploy | |
| - name: Push Chart to Docker Hub | |
| if: ${{ github.ref != 'refs/heads/main' || (github.ref == 'refs/heads/main' && startsWith(github.event.commits[0].message, 'Version Charts')) }} | |
| run: helm push "octopusdeploy-helm-${{ steps.version.outputs.CHART_VERSION }}.tgz" oci://registry-1.docker.io/octopusdeploy |