From 9152b8367e02d3ea29ef49d8efd86d251c46da70 Mon Sep 17 00:00:00 2001 From: mhaswell-bcgov <111079436+mhaswell-bcgov@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:57:25 -0700 Subject: [PATCH] Added support for PRs in chartReleaser workflow (#42) * Added support for PRs in chartReleaser workflow * Added path to image build to avoid rebuilding image when src hasn't changed * Improved wording of workflow input description --- .../workflows/buildTestPublishContainerDeploy.yml | 7 +++++++ .github/workflows/chartReleaser.yml | 12 +++++++++--- helm/Chart.yaml | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/buildTestPublishContainerDeploy.yml b/.github/workflows/buildTestPublishContainerDeploy.yml index 55b36f4b8..c5f5cf48e 100644 --- a/.github/workflows/buildTestPublishContainerDeploy.yml +++ b/.github/workflows/buildTestPublishContainerDeploy.yml @@ -4,6 +4,13 @@ on: types: - published pull_request: + paths: + - 'src/**' + - 'client/**' + - 'server/**' + - 'test/**' + - 'package-lock.json' + - 'Dockerfile' workflow_dispatch: jobs: install-build-lint-and-test: diff --git a/.github/workflows/chartReleaser.yml b/.github/workflows/chartReleaser.yml index ec481ae92..be7c591f3 100644 --- a/.github/workflows/chartReleaser.yml +++ b/.github/workflows/chartReleaser.yml @@ -4,10 +4,13 @@ on: release: types: - published + pull_request: + paths: + - 'helm/**' workflow_dispatch: inputs: chart_version: - description: 'The chart version to create. Must be a valid semver string and should indicate that it is not a release chart version (eg. 5.1.2-pr36).' + description: 'The chart pre-release version label to create. Will be appended to the current version from helm/Chart.yaml (eg. Entering "pr36" with a helm/Chart.yaml at version 5.1.2 produces the final chart tag "5.1.2-pr36").' required: true jobs: @@ -15,12 +18,15 @@ jobs: # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token env: - CHART_VERSION: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.chart_version || null }}" + CHART_VERSION: "${{ (github.event_name == 'workflow_dispatch' && format('-{0}', github.event.inputs.chart_version)) || (github.event_name == 'pull_request' && format('-pr{0}', github.event.pull_request.number)) }}" permissions: contents: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Get helm chart version + id: chart + run: "echo \"version=$(helm show chart helm | grep 'version:' | tail -1 | cut -f2 -d' ')\" >> $GITHUB_OUTPUT" - name: Publish Helm charts uses: stefanprodan/helm-gh-pages@master with: @@ -28,4 +34,4 @@ jobs: charts_dir: ./ branch: gh-pages target_dir: helm - chart_version: ${{ env.CHART_VERSION }} + chart_version: ${{ format('{0}{1}', steps.chart.outputs.version, env.CHART_VERSION || '') }} diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f1c6791eb..e6a098387 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 5.1.2 +version: 5.1.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to