Skip to content

Prepare release 2.14.1 #79

Prepare release 2.14.1

Prepare release 2.14.1 #79

Workflow file for this run

name: Git Diff of last keda versions
on:
pull_request_target:
paths:
- 'keda/**'
jobs:
condition-check:
outputs:
check: ${{ steps.meet-conditions-id.outputs.check}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get keda/ files in base branch
id: base-branch-id
run: |
a=`ls keda | xargs`
echo "baseFiles=$a" >> $GITHUB_OUTPUT
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
gh pr checkout ${{ github.event.number }}
- name: meet conditions for new release
id: meet-conditions-id
run: |
#new directory created in keda/
bf="${{ steps.base-branch-id.outputs.baseFiles }}"
nf=$(ls keda | xargs)
echo "new:"$nf
echo "old:"$bf
# new branch must be different (if new directory was created)
if [ "$nf" != "$bf" ]; then
echo "DIRS ARE DIFF"
check="ok"
else
echo "DIRS ARE THE SAME"
check=
fi
echo $check
echo "check=$check" >> $GITHUB_OUTPUT
setup:
needs: condition-check
if: always() && needs.condition-check.outputs.check != ''
runs-on: ubuntu-latest
outputs:
new_files: ${{ steps.setup-id.outputs.new_files }}
old_files: ${{ steps.setup-id.outputs.old_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
gh pr checkout ${{ github.event.number }}
- name: resources/keda.yaml is updated.
run: |
tester=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.workflow_run.head_sha }} ${{ github.sha }} | xargs)
echo $tester
if [[ ! " ${tester[*]} " =~ "resources/keda.yaml" ]]; then
echo "Did you forget to update resources/keda.yaml file? https://github.com/kedacore/keda-olm-operator/blob/main/RELEASE-PROCESS.MD#1-keda-release-yaml-file"
exit 1
fi
- name: Setup dirs for diff
id: setup-id
run: |
cd keda/
DIRS=$(ls | sort --version-sort |tail -2)
dirs=($DIRS)
dir_old_list=$(find ${dirs[0]} -print)
dir_new_list=$(find ${dirs[1]} -print)
root=$(pwd)
for file in $dir_old_list
do
f=$root"/"$file
if [ -f "$f" ]; then
old_files="$old_files $file"
fi
done
new_files+="{\"new\":["
for file in $dir_new_list
do
f=$root"/"$file
if [ -f "$f" ]; then
new_files+="\"$file\""
le=($dir_new_list)
if [ "$file" != "${le[-1]}" ]; then
new_files+=","
fi
fi
done
new_files+="]}"
echo "::set-output name=new_files::$new_files"
echo "::set-output name=old_files::$old_files"
diff:
if: always() && needs.condition-check.outputs.check != ''
name: Diff files
needs: setup
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJSON(needs.setup.outputs.new_files)}}
env:
of: ${{ needs.setup.outputs.old_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: checkout
run: |
gh pr checkout ${{ github.event.number }}
- name: make diff ${{matrix.new}}
working-directory: keda/
env:
new_file: ${{matrix.new}}
id: diff-id
run: |
regex=$(echo ${{matrix.new}} | awk 'match($0, /[^\.\/]*\.y[a]{0,1}ml/) {print substr($0, RSTART, RLENGTH)}')
old_file=""
for old in $of
do
if [[ "$old" == *"$regex" ]]; then
old_file=$old
break
fi
done
diff_text=""
if [ -n "$old_file" ]; then
if diff_text="$(diff --color -br --suppress-common-lines $old_file $new_file)" && [ $? -ne 1 ]; then
if [ $? -eq 2 ]; then
echo "exit code of diff is 2 which means trouble"
exit 1;
fi
else
## add prefix & postfix
PREFIX=$'\n\n<details>\n\n```diff\n\n'
POSTFIX=$'\n\n```\n\n</details>'
first_line="Diff \`$new_file\` \& \`$old_file\`"
diff_text="${first_line}${PREFIX}${diff_text}${POSTFIX}"
## set file ready for github comment
diff_text="${diff_text//'%'/'%25'}"
diff_text="${diff_text//$'\n'/'%0A'}"
diff_text="${diff_text//$'\r'/'%0D'}"
if [ ${#diff_text} -ge 65536 ]; then
echo "$diff_text"
diff_text="limit exceeded"
fi
fi
else
diff_text="File \`$new_file\` wasn't found in previous version, its brand new!"
fi
echo "::set-output name=body::$diff_text"
echo "::set-output name=old_file::$old_file"
- name: Find comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
comment-author: "github-actions[bot]"
issue-number: ${{github.event.pull_request.number}}
body-includes: "`${{matrix.new}}`"
direction: last
# delete a comment in order to create a new one in "Update comment" so it stays
# at the bottom of the PR discussion
- name: Delete comment
id: del-comment
if: steps.find-comment.outputs.comment-id != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --method DELETE -H "Accept: application/vnd.github+json" \
/repos/${{github.repository_owner}}/${{github.event.repository.name}}\
/issues/comments/${{steps.find-comment.outputs.comment-id}}
# Create a brand new comment (usually when PR is created)
- name: Create comment
if: steps.diff-id.outputs.body != '' && steps.diff-id.outputs.body != 'limit exceeded' && (steps.diff-id.outputs.body == steps.find-comment.outputs.comment-body || steps.find-comment.outputs.comment-id == '')
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
# max character length is 65536 (2022/10/06)
body: |
${{steps.diff-id.outputs.body}}
reactions: rocket
- name: Create comment over limit
if: steps.diff-id.outputs.body == 'limit exceeded'
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{github.event.pull_request.number}}
body: Diff output of `${{matrix.new}}` is too large - character limit 65536 exceeded for github comment
reactions: confused
# this "updates" a comment (creates a new one as an update)
- name: Update comment
if: steps.diff-id.outputs.body != '' && steps.diff-id.outputs.body != 'limit exceeded' && steps.diff-id.outputs.body != steps.find-comment.outputs.comment-body && steps.find-comment.outputs.comment-body != ''
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
# max character length is 65536 (2022/10/06)
body: |
${{steps.diff-id.outputs.body}}
reactions: eyes