-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an organisation or owner check to run the action
- [Forks problem: add an organisation or owner check to run the action · Issue #2 · Comfy-Org/publish-node-action]( Comfy-Org/publish-node-action#2 (comment) )
- Loading branch information
Showing
11 changed files
with
65 additions
and
54 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
import pMap from "p-map"; | ||
// import { chalk } from "zx"; | ||
import { clone_modify_push_Branches } from "./clone_modify_push_Branches"; | ||
import { createGithubForkForRepo } from "./createGithubForkForRepo"; | ||
import { createGithubPullRequest } from "./createGithubPullRequest"; | ||
import type { GithubPull } from "./gh/GithubPull"; | ||
import { makeUpdateTomlLicenseBranch } from "./makeUpdateTomlLicenseBranch"; | ||
import { parsePulls } from "./parsePullsState"; | ||
|
||
if (import.meta.main) { | ||
// test repo | ||
const test_repo = "https://github.com/snomiao/ComfyNode-Registry-test"; | ||
console.info(await createComfyRegistryPullRequests(test_repo)); | ||
} | ||
export async function createComfyRegistryPullRequests(upstreamRepoUrl: string) { | ||
console.log("forking " + upstreamRepoUrl); | ||
const forkedRepo = await createGithubForkForRepo(upstreamRepoUrl); | ||
|
||
console.log("modifing " + forkedRepo.html_url); | ||
const PR_REQUESTS = await clone_modify_push_Branches(upstreamRepoUrl, forkedRepo.html_url); | ||
const prs = await pMap(PR_REQUESTS, async ({ type, ...prInfo }) => await createGithubPullRequest({ ...prInfo })); | ||
|
||
console.log("Registry PRs DONE"); | ||
|
||
return ([...prs] as GithubPull[]).map((e) => parsePulls([e])[0]); | ||
} | ||
|
||
export async function clone_modify_push_Branches_for_updateTomlLicense(upstreamUrl: string, forkUrl: string) { | ||
return (await Promise.all([makeUpdateTomlLicenseBranch(upstreamUrl, forkUrl)])) | ||
.flatMap((e) => (e ? [e] : [])) | ||
.map(({ body, branch, title, type }) => ({ | ||
body, | ||
branch, | ||
title, | ||
type, | ||
srcUrl: forkUrl, | ||
dstUrl: upstreamUrl, | ||
})); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
import type { Task } from "@/packages/mongodb-pipeline-ts/Task"; | ||
import DIE from "@snomiao/die"; | ||
import { gh } from "./gh"; | ||
import type { AwaitedReturnType } from "./types/AwaitedReturnType"; | ||
|
||
export const ghUser = (await gh.users.getAuthenticated()).data; | ||
export const ghUser = ( | ||
await gh.users.getAuthenticated().catch((error) => { | ||
throw new Error( | ||
`FAIL TO GET AUTHENTICATED USER INFO, CHECK ${!!process.env.GH_TOKEN ? "[?]" : "[ ]"}GH_TOKEN and ${!!process.env.GH_TOKEN_COMFY_PR ? "[?]" : "[ ]"}GH_TOKEN_COMFY_PR`, | ||
{ cause: error }, | ||
); | ||
}) | ||
).data; | ||
|
||
console.log("Fetch Current Github User..."); | ||
console.log(`Current Github User: ${ghUser.login} <${ghUser.email}>`); | ||
console.log(`GH_TOKEN User: ${ghUser.login} <${ghUser.email}>`); | ||
export type GHUser = Task<AwaitedReturnType<typeof gh.users.getByUsername>["data"]>; | ||
export const GIT_USEREMAIL = | ||
process.env.GIT_USEREMAIL || (ghUser.email && ghUser.email) || DIE("Missing env.GIT_USEREMAIL"); | ||
export const GIT_USERNAME = | ||
process.env.GIT_USERNAME || (ghUser.email && ghUser.name) || DIE("Missing env.GIT_USERNAME"); | ||
|
||
// read env/parameters | ||
console.log(`GIT COMMIT USER: ${GIT_USERNAME} <${GIT_USEREMAIL}>`); |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish to Comfy registry | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
paths: | ||
- "pyproject.toml" | ||
|
||
jobs: | ||
publish-node: | ||
name: Publish Custom Node to registry | ||
runs-on: ubuntu-latest | ||
# if this is a forked repository. Skipping the workflow. | ||
if: github.event.repository.fork == false | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Publish Custom Node | ||
uses: Comfy-Org/publish-node-action@main | ||
with: | ||
## Add your own personal access token to your Github Repository secrets and reference it here. | ||
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} |
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