Download icons from Figma #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Download icons from Figma | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
deployments: read | |
pull-requests: write | |
jobs: | |
download: | |
runs-on: ubuntu-latest | |
name: Download icons from Figma | |
environment: main | |
defaults: | |
run: | |
working-directory: ./packages/icons | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 | |
with: | |
# Required when using a PAT for opening the PR | |
persist-credentials: false | |
- name: Use Node.js | |
uses: ./.github/actions/setup-node | |
- name: Download icons | |
run: npx @talend/figma-icons-downloader | |
env: | |
FIGMA_ACCESS_TOKEN: ${{ secrets.STORYBOOK_FIGMA_ACCESS_TOKEN }} | |
- name: Generate changeset & PR body | |
id: get-pr-body | |
run: | | |
cd ../.. | |
git add ./packages/icons/src | |
while read STATUS ADDR | |
do | |
icon=`basename $ADDR .svg` | |
size=`basename $(dirname $ADDR)` | |
semver=`sed 's/A/minor/;s/D/major/;s/M/patch/' <<< $STATUS` | |
verb=`sed 's/A/added/;s/D/removed/;s/M/changed/' <<< $STATUS` | |
echo -e "---\n'@talend/icons': $semver\n---\n\n$verb icon \`$icon\` in size \`$size\`" > .changeset/$icon-$size-$semver.md | |
done < <(git diff --name-status HEAD ./packages/icons/src/icon/**/*.svg) | |
git add .changeset | |
body=$(git diff --name-only HEAD .changeset/*.md | xargs -L1 sed -n '5p') | |
body="${body//$'\n'/'%0A'}" | |
echo ::set-output name=body::$body | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 #v5.0.2 | |
with: | |
commit-message: "chore(icons): from Figma" | |
title: "chore(icons): from Figma" | |
body: ${{ steps.get-pr-body.outputs.body }} | |
branch: ci/icons | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# Opening a PR with default token would not start build & test action | |
GITHUB_TOKEN: ${{ secrets.CHANGESET_GITHUB_TOKEN }} |