Skip to content

Commit

Permalink
chore: prevent from running on multiple approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallAsch committed Nov 14, 2024
1 parent 163eaef commit 5fc36a1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,24 @@ jobs:
sparse-checkout: charts
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up chart-testing
uses: helm/chart-testing-action@v2

- name: Check if version bump is needed
id: check_bump
run: |
ct lint --config .github/linters/ct.yaml --source master | grep -q 'chart version not ok. Needs a version bump!'
needsBump=$?
if [ $needsBump -eq 0 ]; then
echo "needsBump=true" >> "$GITHUB_OUTPUT"
else
echo "needsBump=false" >> "$GITHUB_OUTPUT"
fi
- name: Cache binaries
id: cache-bin
if: ${{ steps.check_bump.outputs.needsBump == 'true' }}
uses: actions/cache@v4
env:
cache-name: cache-semver
Expand All @@ -60,18 +76,20 @@ jobs:
${{ runner.os }}-
- name: Setup semver
if: steps.cache-bin.outputs.cache-hit != 'true'
if: ${{ steps.check_bump.outputs.needsBump == 'true' && steps.cache-bin.outputs.cache-hit != 'true' }}
run: |
mkdir -p bin
wget -O bin/semver \
https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.4.0/src/semver
chmod +x bin/semver
- name: Setup PATH
if: ${{ steps.check_bump.outputs.needsBump == 'true' }}
run: |
echo "$GITHUB_WORKSPACE/bin" >> "$GITHUB_PATH"
- name: Compute version
if: ${{ steps.check_bump.outputs.needsBump == 'true' }}
id: get_version
env:
PATCH_LABEL: "${{ contains(github.event.pull_request.labels.*.name, 'chart: patch') }}"
Expand Down Expand Up @@ -101,6 +119,7 @@ jobs:
echo "new=${new_ver}" >> "$GITHUB_OUTPUT"
- name: Update Chart Version
if: ${{ steps.check_bump.outputs.needsBump == 'true' }}
shell: bash
run: |
sed -i "s/version: ${{ steps.get_version.outputs.last }}/version: ${{ steps.get_version.outputs.new }}/g" "charts/${APP}/Chart.yaml"
Expand All @@ -111,10 +130,12 @@ jobs:
helm-docs --chart-search-root charts --chart-to-generate charts/${APP}
- name: Commit Changes
env:
message: ${{ steps.check_bump.outputs.needsBump == 'true' && format('to v{0}', steps.get_version.outputs.new) || 'documentation' }}
run: |
git config user.email '<>'
git config user.name github-actions
if ! git diff-index --quiet HEAD; then
git commit -m "chore: bump $APP chart to v${{ steps.get_version.outputs.new }}" --all
git commit -m "chore: update $APP chart $message" --all
git push origin "HEAD:$GITHUB_HEAD_REF"
fi

0 comments on commit 5fc36a1

Please sign in to comment.