🚀 Release (Figma) #622
This file contains hidden or 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: 🚀 Release (Figma) | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| brand: | |
| type: choice | |
| description: Library to export | |
| required: true | |
| default: "all" | |
| options: | |
| - all | |
| - telefonica | |
| - o2 | |
| - o2-new | |
| - blau | |
| - vivo (disabled) | |
| draft: | |
| type: boolean | |
| default: true | |
| description: Draft PR | |
| branch: | |
| type: string | |
| description: Branch to export icons to | |
| default: "import-figma-icons" | |
| required: false | |
| env: | |
| MISTICA_ICONS_FILE_URL: https://www.figma.com/design/JXy7Y07eb0Axg0ThVRWKju/Default-Icons-Set?node-id=0-71&t=1nybaZ1fzHqRq80C-1 | |
| O2_FILE_URL: https://www.figma.com/file/wHTqJ7KDhGKrNSNpmMb9nW/?node-id=611%3A3298 | |
| O2_NEW_FILE_URL: https://www.figma.com/design/CjvgrHEIycSQ6exznxnFXT/O2?m=auto&node-id=4-0&t=0HBFuR3VADUhh5Zr-1 | |
| BLAU_FILE_URL: https://www.figma.com/design/czemeClWRGBI8oF7caNa5m/Blau?node-id=0-1&node-type=canvas&t=CM2TIEBRzYVgRX5A-0 | |
| VIVO_FILE_URL: https://www.figma.com/design/EApRpjaTyUOwW5VQU2ZqgP/Vivo?node-id=4-0&node-type=canvas&t=pnjxXOX7B7hd3BmJ-0 | |
| jobs: | |
| export-icons: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: figma-import | |
| steps: | |
| - name: Validate inputs | |
| id: inputs | |
| env: | |
| INPUT_BRANCH: ${{ github.event.inputs.branch || 'import-figma-icons' }} | |
| run: | | |
| # Validate branch: only alphanumeric, hyphens, slashes, dots and underscores | |
| if ! printf '%s' "$INPUT_BRANCH" | grep -Eq '^[a-zA-Z0-9/_.-]+$'; then | |
| echo "❌ Invalid branch name: $INPUT_BRANCH" | |
| echo "Only alphanumeric, hyphens, slashes, dots and underscores allowed" | |
| exit 1 | |
| fi | |
| echo "✅ Valid branch: $INPUT_BRANCH" | |
| echo "branch=$INPUT_BRANCH" >> "$GITHUB_OUTPUT" | |
| - uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install SVG/PDF tooling | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y librsvg2-bin libimage-exiftool-perl qpdf | |
| - name: Ensure Yarn CLI is available | |
| run: npm install -g yarn | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: yarn | |
| - name: Install project dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Checkout branch or create new one | |
| env: | |
| TARGET_BRANCH: ${{ steps.inputs.outputs.branch }} | |
| run: | | |
| # Use validated branch variable | |
| git fetch origin "$TARGET_BRANCH" || true | |
| git checkout -B "$TARGET_BRANCH" | |
| - name: Run figma export | |
| env: | |
| FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} | |
| BRAND: ${{ github.event.inputs.brand }} | |
| run: | | |
| # Brand is safe (validated by type: choice) | |
| yarn figma-export -- --brand "$BRAND" | |
| - name: Detect changes | |
| id: changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Prepare PR metadata | |
| if: ${{ steps.changes.outputs.changed == 'true' }} | |
| id: pr | |
| env: | |
| BRAND: ${{ github.event.inputs.brand }} | |
| BRANCH_NAME: ${{ steps.inputs.outputs.branch }} | |
| REPO_SLUG: ${{ github.repository }} | |
| DEFAULT_URL: ${{ env.MISTICA_ICONS_FILE_URL }} | |
| O2_URL: ${{ env.O2_FILE_URL }} | |
| O2_NEW_URL: ${{ env.O2_NEW_FILE_URL }} | |
| BLAU_URL: ${{ env.BLAU_FILE_URL }} | |
| VIVO_URL: ${{ env.VIVO_FILE_URL }} | |
| run: | | |
| # Use validated variables | |
| case "$BRAND" in | |
| all) | |
| TITLE="Update Figma icons" | |
| BODY="New version of icons exported from [Mistica Icons]($DEFAULT_URL), [O2]($O2_URL), [O2-new]($O2_NEW_URL), [Blau]($BLAU_URL) & [Vivo]($VIVO_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| telefonica) | |
| TITLE="Update Mística icons" | |
| BODY="New version of icons exported from [Mistica Icons]($DEFAULT_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| o2) | |
| TITLE="Update O2 icons" | |
| BODY="New version of icons exported from [O2]($O2_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| o2-new) | |
| TITLE="Update O2-new icons" | |
| BODY="New version of icons exported from [O2-new]($O2_NEW_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| blau) | |
| TITLE="Update Blau icons" | |
| BODY="New version of icons exported from [Blau]($BLAU_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| vivo) | |
| TITLE="Update Vivo icons" | |
| BODY="New version of icons exported from [Vivo]($VIVO_URL) | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| *) | |
| TITLE="Update icons" | |
| BODY="New icons exported. | |
| - [ ] [Review icon table in $BRANCH_NAME](https://github.com/$REPO_SLUG/tree/$BRANCH_NAME/ICON_TABLE.md)" | |
| ;; | |
| esac | |
| echo "title=$TITLE" >> "$GITHUB_OUTPUT" | |
| { | |
| echo "body<<EOF" | |
| echo "$BODY" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Commit & Push | |
| if: ${{ steps.changes.outputs.changed == 'true' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN_MISTICA }} | |
| TARGET_BRANCH: ${{ steps.inputs.outputs.branch }} | |
| run: | | |
| # Configure git credentials using GITHUB_TOKEN | |
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git | |
| git config user.name "github-actions" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "Figma icons updated" | |
| # Use validated branch variable | |
| git push --force-with-lease origin "$TARGET_BRANCH" | |
| - name: Create Pull-Request | |
| if: ${{ steps.changes.outputs.changed == 'true' }} | |
| uses: repo-sync/pull-request@v2 | |
| with: | |
| source_branch: ${{ steps.inputs.outputs.branch }} | |
| destination_branch: production | |
| pr_title: ${{ steps.pr.outputs.title }} | |
| pr_body: ${{ steps.pr.outputs.body }} | |
| pr_draft: ${{ github.event.inputs.draft }} | |
| github_token: ${{ secrets.GH_TOKEN_MISTICA }} |