name: Add Changed Icons comment on: pull_request_target: paths: - 'icons/*.svg' permissions: pull-requests: write contents: write jobs: add-changed-icons-comment: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 ref: refs/pull/${{ github.event.pull_request.number }}/merge - name: Get changed files id: changed-files uses: tj-actions/changed-files@v35 with: files: icons/*.svg - name: Generate comment id: generate-comment run: | delimiter="$(openssl rand -hex 8)" echo "body<<$delimiter" >> $GITHUB_OUTPUT for file in ${{ steps.changed-files.outputs.all_changed_files }}; do cat "$file" | # get file content tr '\n' ' ' | # remove line breaks sed -e 's/]*>//g' | # remove attributes from svg element base64 -w 0 | # encode svg sed "s|.*|\"$file\" |" done | tr '\n' ' ' >> $GITHUB_OUTPUT echo >> $GITHUB_OUTPUT echo "$delimiter" >> $GITHUB_OUTPUT - name: Find Comment uses: peter-evans/find-comment@v2 id: fc with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: Added or changed icons - name: Create or update comment uses: peter-evans/create-or-update-comment@v2 with: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | ### Added or changed icons
Icon X-rays ${{ steps.generate-comment.outputs.body }}
edit-mode: replace