tabler-icons/.github/workflows/validate-pr.yml

93 lines
2.5 KiB
YAML

name: Validate PR
on: [pull_request]
permissions:
pull-requests: write
jobs:
validate-pr:
if: github.repository == 'tabler/tabler-icons'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Add in progress comment
id: add-in-progress-comment
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: validate
mode: upsert
message: |
🔄 Icons are being validated... Please wait...
continue-on-error: true
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Validate icons
id: validate
run: pnpm run --silent validate > ./comment-markup.md
continue-on-error: true
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ./comment-markup.md
comment-tag: validate
mode: recreate
- name: Generate icons comment
id: generate-icons-comment
run: pnpm run --silent generate-icons-comment > ./comment-icons.md || true
continue-on-error: true
- name: Check if icons were added
id: check-icons
run: |
if [ -s ./comment-icons.md ]; then
echo "has_icons=true" >> $GITHUB_OUTPUT
else
echo "has_icons=false" >> $GITHUB_OUTPUT
fi
- name: Comment PR with added icons
if: steps.check-icons.outputs.has_icons == 'true'
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ./comment-icons.md
comment-tag: added-icons
mode: upsert
- name: Remove comment with added icons
if: steps.check-icons.outputs.has_icons == 'false'
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: added-icons
mode: delete