Skip to content

Rename 0x382bb369d343125bfb2117af9c149795c6c65c50.png to 0x74b7F16337… #109

Rename 0x382bb369d343125bfb2117af9c149795c6c65c50.png to 0x74b7F16337…

Rename 0x382bb369d343125bfb2117af9c149795c6c65c50.png to 0x74b7F16337… #109

Workflow file for this run

name: pr-checks
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
pull-requests: write
jobs:
changed_files:
runs-on: ubuntu-latest
name: PR automated checks
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42
- name: Process changed files
id: changes-errors
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo 'errorsStr<<EOF' >> $GITHUB_OUTPUT
for file in $ALL_CHANGED_FILES; do
echo "Processing file: $file"
if [[ $file != images/* ]] && [[ $file != platforms/* ]] ;
then
errorText="Only additions of token icons (in the /images folder) or platform logos (in the /platforms folder) are permitted"
errorOutputText="- Error with \`$file\`: $errorText"
echo "::error file=$file::$errorText"
echo "$errorOutputText" >> $GITHUB_OUTPUT
fi
# Only check token icon additions, not platform icons which don't have anything automated
if [[ $file == images/assets* ]] ;
then
if [[ $file != *.png ]] ;
then
errorText="The new icon must be a PNG file"
errorOutputText="- Error with \`$file\`: $errorText"
echo "::error file=$file::$errorText"
echo "$errorOutputText" >> $GITHUB_OUTPUT
elif [[ ! $file =~ ^images/assets(-[a-z]+)*/[a-z0-9]+\.png$ ]] ;
then
errorText="The new icon's filename must be entirely lowercase"
errorOutputText="- Error with \`$file\`: $errorText"
echo "::error file=$file::$errorText"
echo "$errorOutputText" >> $GITHUB_OUTPUT
fi
fi
done
echo 'EOF' >> $GITHUB_OUTPUT
- name: Check if errors
id: check-if-errors
env:
ERRORS: ${{ steps.changes-errors.outputs.errorsStr }}
run: |
errorsStrLength=${#ERRORS}
echo "prev output : $ERRORS $errorsStrLength"
if (( errorsStrLength == 0 ));
then
echo 'hasErrors=false'
echo "hasErrors=false" >> "$GITHUB_OUTPUT"
else
echo 'hasErrors=true'
echo "hasErrors=true" >> "$GITHUB_OUTPUT"
fi
- name: Comment on PR if error
env:
ERRORS: ${{ steps.changes-errors.outputs.errorsStr }}
HAS_ERRORS: ${{ steps.check-if-errors.outputs.hasErrors }}
uses: thollander/actions-comment-pull-request@v2
if: ${{ env.HAS_ERRORS == 'true' }}
with:
message: |
Changes are required before your pull request can be reviewed:
${{ env.ERRORS }}
- name: Exit with error
env:
ERRORS: ${{ steps.changes-errors.outputs.errorsStr }}
HAS_ERRORS: ${{ steps.check-if-errors.outputs.hasErrors }}
if: ${{ env.HAS_ERRORS == 'true' }}
run: |
mapfile myarray <<< $ERRORS
for ((i = 0; i < ${#myarray[@]}; ++i)); do
echo "::error::${myarray[i]}"
done
exit 1