Skip to content

Update ALL visual assets in master #15

Update ALL visual assets in master

Update ALL visual assets in master #15

name: Update ALL Visual Assets
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 1-5"
issue_comment:
types: [created]
concurrency:
group: visual-assets-all-${{ github.ref }}
cancel-in-progress: true
run-name: "Update ALL visual assets in ${{ github.ref_name }}"
jobs:
ignore-list:
name: Generate ignore-list.txt
runs-on: ubuntu-latest
steps:
- name: Acknowledge Comment - Start
id: check
uses: shanegenschaw/[email protected]
if: github.event_name == 'issue_comment'
with:
trigger: 'Update'
reaction: eyes
env:
GITHUB_TOKEN: '${{ secrets.TOOLS_PAT }}'
- name: 'Generate ignore-list.txt'
if: (github.event_name == 'issue_comment' && steps.check.outputs.triggered == 'true') || github.event_name != 'issue_comment'
run: |
gh pr list --repo ${{ github.repository }} --state open --json id,number --jq ".[].number" | \
while read -r line; do \
echo $line; \
gh api repos/${{ github.repository }}/pulls/$line/files -q ".[].filename" >> ignore-list.txt ; \
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact ignore-list
if: (github.event_name == 'issue_comment' && steps.check.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: actions/upload-artifact@v4
with:
name: ignore-list
path: ignore-list.txt
outputs:
triggered: ${{ steps.check.outputs.triggered }}
validate:
name: Validate
runs-on: ubuntu-latest
needs: ignore-list
steps:
- name: Checkout
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 'Setup markdown-figma'
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: MiguelDomingues/[email protected]
- name: Download artifact ignore-list
uses: actions/download-artifact@v4
with:
name: ignore-list
- name: 'Update visual assets'
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
run:
markdown-figma --max-updates "${{ vars.FIGMA_EXPORT_FILES_LIMIT }}" --input src/ --api-token "${{ secrets.FIGMA_API_TOKEN }}" --pattern "*.md" --export "images" --similarity ${{ vars.FIGMA_SIMILARITY_THRESHOLD }} --svg-visual-check-only --parse-html --report "report.md" --ignore "ignore-list.txt"
- name: 'Remove ignore-list.txt'
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
run: |
rm ignore-list.txt
- name: Upload artifact report
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: actions/upload-artifact@v4
with:
name: report
path: report.md
- name: 'Generate PR body'
id: get-pr-body
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
run: |
cat .github/visual-assets-all.md >> pr-body.txt
echo "" >> pr-body.txt
cat report.md >> pr-body.txt
- name: Upload artifact pr-body
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: actions/upload-artifact@v4
with:
name: pr-body
path: pr-body.txt
- name: Create Pull Request
if: (github.event_name == 'issue_comment' && needs.ignore-list.outputs.triggered == 'true') || github.event_name != 'issue_comment'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.TOOLS_PAT }}
commit-message: Update visual assets in ${{ github.ref_name }}
signoff: false
branch: pr-${{ github.ref_name }}-figma
delete-branch: false
title: Update visual assets
reviewers: ${{ github.actor }}
body-path: pr-body.txt
draft: true
labels: figma,skip-jira
add-paths: |
**.svg
**.png
**.gif
- name: Acknowledge Comment - Finish
uses: khan/[email protected]
if: github.event_name == 'issue_comment'
with:
trigger: 'Update'
reaction: rocket
env:
GITHUB_TOKEN: '${{ secrets.TOOLS_PAT }}'