Fix/serviceaccount creation #3
Workflow file for this run
This file contains 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: Check for new release | |
on: | |
pull_request: | |
types: [opened, synchronize, labeled, unlabeled] | |
jobs: | |
check_for_release: | |
name: Check For Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check for appVersion changes | |
run: | | |
echo "Checking for appVersion changes..." | |
if git diff origin/${{ github.base_ref }} -- deployments/chart/Chart.yaml | grep -qe "^[+-]appVersion: "; then | |
app_version_change=$(echo "version changed") | |
echo "app_version_change=$app_version_change" >> $GITHUB_ENV | |
else | |
app_version_change=$(echo "No appVersion changes detected.") | |
echo "app_version_change=$app_version_change" >> $GITHUB_ENV | |
fi | |
- name: Remove new version label | |
if: ${{ env.app_version_change == 'No appVersion changes detected.' }} | |
run: | | |
echo "No appVersion changes detected. Removing new version label" | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "new release" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fail if changes occured | |
if: ${{ !contains(github.event.pull_request.labels.*.name, 'new release') }} | |
run: | | |
if [ "${{ env.app_version_change }}" == "version changed" ]; then | |
gh pr edit ${{ github.event.pull_request.number }} --add-label "needs approval" | |
echo "Version changed, exiting..." | |
exit 1 | |
else | |
echo "No appVersion changes detected." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Remove approval label | |
run: | | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "needs approval" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
post_message: | |
name: Post Message To Warn Of New Release | |
runs-on: ubuntu-latest | |
needs: check_for_release | |
if: ${{ failure() && !contains(github.event.pull_request.labels.*.name, 'needs approval') && github.event.action != 'labeled' && github.event.action != 'unlabeled' }} | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract appVersion | |
id: extract_appversion | |
run: | | |
appversion=$(yq e '.appVersion' ./deployments/chart/Chart.yaml) | |
echo "appversion=$appversion" >> $GITHUB_ENV | |
- name: Post warning comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: "⚠️ Warning: Merging this PR will result in a new release because the `appVersion` in Chart.yaml has changed to `${{ env.appversion }}`. Please confirm this by adding the `new release` label before merging." |