Skip to content

Commit

Permalink
Merge pull request #2 from UbloImmo/chore/update-icons
Browse files Browse the repository at this point in the history
Chore/update icons
  • Loading branch information
blksnk authored Jul 22, 2024
2 parents 731ae35 + 5dee929 commit bb5baa7
Show file tree
Hide file tree
Showing 52 changed files with 158,597 additions and 10,145 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FIGMA_TOKEN # Personal figma API token
FIGMA_TEAM_ID # Figma team ID
FIGMA_FILE_URLS # Comma-separated list of figma files URLS to filter team styles
FIGMA_ICONS_FILE_URL # Figma file URL pointing to a file that holds icon components
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
lib
generated
65 changes: 65 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint-disable no-undef */
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended",
"plugin:storybook/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
settings: {
react: {
version: "detect",
},
propWrapperFunctions: ["forbidExtraProps"],
linkComponents: [
"Hyperlink",
{
name: "Link",
linkAttribute: "to",
},
],
},
plugins: ["react", "react-hooks", "@typescript-eslint"],
ignorePatterns: ["**/dist/*.js"],
rules: {
// generic
"no-console": [
"warn",
{
allow: ["warn", "error"],
},
],
"no-var": "error",
eqeqeq: ["error", "always"],
"no-dupe-keys": "error",
// react
"react/react-in-jsx-scope": 0,
"react-hooks/exhaustive-deps": 2,
"react/display-name": 0,
// typescript
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": "warn",
},
};
178 changes: 178 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Token update
run-name: Updating figma tokens
on:
deployment: null
schedule:
- cron: "30 5 * * 6"
workflow_dispatch: null

jobs:
update_tokens:
name: "Figma token update"
runs-on: ubuntu-latest
outputs:
changes: ${{steps.token_update.outputs.changes}}
version: ${{steps.token_update.outputs.version}}
message: ${{steps.token_update.outputs.message}}
steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Setup jq
uses: dcarbone/[email protected]

- name: Check jq
run: |
which jq
jq --version
- name: Setup Bun
id: bun_setup
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Check bun
run: |
which bun
bun --version
- name: Install dependencies
id: bun_install
run: bun install

- name: Setup environment
id: env_setup
env:
FIGMA_TOKEN: ${{secrets.FIGMA_TOKEN}}
FIGMA_TEAM_ID: ${{secrets.FIGMA_TEAM_ID}}
FIGMA_FILE_URLS: ${{secrets.FIGMA_FILE_URLS}}
FIGMA_ICONS_FILE_URL: ${{secrets.FIGMA_ICONS_FILE_URL}}
run: |
touch .env
echo "FIGMA_TOKEN=${{env.FIGMA_TOKEN}}" >> .env
echo "FIGMA_TEAM_ID=${{env.FIGMA_TEAM_ID}}" >> .env
echo "FIGMA_FILE_URLS=${{env.FIGMA_FILE_URLS}}" >> .env
echo "FIGMA_ICONS_FILE_URL"="${{env.FIGMA_ICONS_FILE_URL}}" >> .env
- name: Token update
id: token_update
run: |
# create temp
mkdir temp
touch temp/output.json
# create lib dir if it doesn't exist
mkdir -p lib
# update figma tokens
bun run update
# evaluate script output
changes=$(echo $(<./temp/output.json) | jq ".changes")
if [[ "$changes" == "false" ]]
then
# no commit or publish needed
echo "changes=false" >> $GITHUB_OUTPUT
else
# new changes have been generated
# pull message and version from script output
message=$(echo $(<./temp/output.json) | jq ".message")
version=$(echo $(<./temp/output.json) | jq ".version")
# expose output to further steps
echo "changes=true" >> $GITHUB_OUTPUT
echo "message=$message" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
fi
cat $GITHUB_OUTPUT
env:
FIGMA_TOKEN: ${{secrets.FIGMA_TOKEN}}
FIGMA_TEAM_ID: ${{secrets.FIGMA_TEAM_ID}}
FIGMA_FILE_URLS: ${{secrets.FIGMA_FILE_URLS}}
FIGMA_ICONS_FILE_URL: ${{secrets.FIGMA_ICONS_FILE_URL}}

- name: Git setup
id: git_setup
env:
CI_COMMIT_AUTHOR: CI
CI_COMMIT_EMAIL: [email protected]
CI_COMMIT_MESSAGE: ${{steps.token_update.outputs.message}}
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
- name: Git commit and push
id: git_push
if: steps.token_update.outputs.changes == 'true'
env:
CI_COMMIT_MESSAGE: ${{steps.token_update.outputs.message}}
run: |
git add .
git commit -m ${{env.CI_COMMIT_MESSAGE}}
git push
- name: Revision bump
id: revision_bump
if: steps.token_update.outputs.changes == 'true'
run: npm version patch

- name: Revision push
id: revision_push
if: steps.token_update.outputs.changes == 'true'
run: git push

publish_package:
name: "NPM package publish"
needs: update_tokens
if: needs.update_tokens.outputs.changes == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

create_release:
name: "Create release"
needs: update_tokens
if: needs.update_tokens.outputs.changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install zip
uses: montudor/[email protected]

- name: Bundle lib files
id: release_bundle
run: |
release_file="release-${{ needs.update_tokens.outputs.version }}.zip"
echo "release_file=$release_file" >> $GITHUB_OUTPUT
zip -qq -r "$release_file" lib
- name: Create release
id: release_create
uses: softprops/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.update_tokens.outputs.version }}
name: Release v${{ needs.update_tokens.outputs.version }}
body: |
Changes in this release:
${{ needs.update_tokens.outputs.message }}
draft: false
prerelease: false
files: |
${{ steps.release_bundle.outputs.release_file }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,4 @@ dist
# Finder (MacOS) folder config
.DS_Store

temp/
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
src/
temp/
.env
.env.example
.gitignore
bun.lockb
tsconfig.json
.github
Loading

0 comments on commit bb5baa7

Please sign in to comment.