Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Code connect #29

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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