Skip to content

Commit

Permalink
Merge pull request #29 from ZebraDevs/code-connect
Browse files Browse the repository at this point in the history
feat: Added code connect integration for Figma
  • Loading branch information
mikecoomber authored Oct 9, 2024
2 parents 33b57ef + fef5eed commit afea682
Show file tree
Hide file tree
Showing 45 changed files with 6,982 additions and 303 deletions.
10 changes: 10 additions & 0 deletions .github/create_code_connect/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Create Code Connect"
description: "Generate code connect files"
inputs:
figma-access-token:
description: "The personal access token given by Figma. Required to make API calls"
required: true

runs:
using: "node20"
main: "index.js"
11 changes: 11 additions & 0 deletions .github/create_code_connect/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readFileSync } from "fs";
import { generateCodeConnectFile } from "../../dist/scripts/code-connect/generate-code-connect-file.js";

const main = async () => {
const iconManifest = new Map(Object.entries(JSON.parse(readFileSync("../../outputs/icon-manifest.json"))));
const dir = "../../outputs";

generateCodeConnectFile(dir, iconManifest);
};

main();
10 changes: 10 additions & 0 deletions .github/publish_code_connect/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Publish Code Connect"
description: "Publish code connect files"
inputs:
figma-access-token:
description: "The personal access token given by Figma. Required to make API calls"
required: true

runs:
using: "node20"
main: "index.js"
13 changes: 13 additions & 0 deletions .github/publish_code_connect/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import core from "@actions/core";
import util from "util";
import { exec } from "child_process";
const asyncExec = util.promisify(exec);

const FIGMA_ACCESS_TOKEN = core.getInput("figma-access-token") || process.env.FIGMA_ACCESS_TOKEN;

const { stdout, stderr } = await asyncExec(`npx figma connect publish --token ${FIGMA_ACCESS_TOKEN}`, {
cwd: "../..",
});

console.log(stdout);
console.error(stderr);
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
figma-access-token: ${{ secrets.FIGMA_PERSONAL_ACCESS_TOKEN }}
- name: Icons changed
run: echo ${{ steps.fetch_icons.outputs.files_changed }}
- name: Create code connect files
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
uses: ./.github/create_code_connect
- name: Get current date
if: ${{ steps.fetch_icons.outputs.files_changed == 'true'}}
id: date
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/on-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish code connect
uses: ./.github/publish_code_connect
with:
figma-access-token: ${{ secrets.FIGMA_PERSONAL_ACCESS_TOKEN }}

update_npm_dependencies:
needs: publish
Expand Down
6 changes: 6 additions & 0 deletions figma.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"codeConnect": {
"include": ["outputs/code-connect.figma.ts"],
"exclude": ["test/**/*.figma.ts"]
}
}
Loading

0 comments on commit afea682

Please sign in to comment.