chore:! update workflow

This commit is contained in:
Andrei O 2024-07-27 01:21:03 +03:00
parent 249e8cf668
commit b0b0c7d8c2
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
3 changed files with 48 additions and 28 deletions

View File

@ -8,7 +8,13 @@ on:
inputs:
version:
description: 'Version'
type: string
required: true
fconly:
description: 'FC Only'
type: boolean
required: true
default: false
jobs:
run-bun-script:
@ -21,8 +27,6 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
version: '1.1.18'
- name: Install Dependencies
run: bun install

View File

@ -8,7 +8,13 @@ on:
inputs:
version:
description: 'Version'
type: string
required: true
fconly:
description: 'FC Only'
type: boolean
required: true
default: false
jobs:
run-bun-script:
@ -21,8 +27,6 @@ jobs:
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
version: '1.1.18'
- name: Install Dependencies
run: bun install

View File

@ -3,13 +3,14 @@ import { FCHubUtils } from 'farcaster-hub-utils'
const args = Bun.argv.slice(2);
const secrets = args[0]
const secrets = args[0]
const event = args[1]
const action = args[2]
type TGithubEvent = {
inputs: {
version: string
fconly: boolean
},
forced: boolean,
repository: {
@ -34,12 +35,15 @@ type TGithubEvent = {
username: string
}
}
}
}
const main = async () => {
const ENABLED = true;
let YUP_PK = '';
let FC_SIGNER = ''
let HUB_URL = ''
let HUB_USER = ''
let HUB_PASS = ''
let GithubEvent: TGithubEvent = {} as TGithubEvent;
const USER_FID = 709233;
@ -49,53 +53,61 @@ const main = async () => {
const parsedSecrets = JSON.parse(secrets);
YUP_PK = parsedSecrets.YUP_PK;
FC_SIGNER = parsedSecrets.FC_SIGNER;
HUB_URL = parsedSecrets.HUB_URL;
HUB_USER = parsedSecrets.HUB_USER;
HUB_PASS = parsedSecrets.HUB_PASS;
GithubEvent = JSON.parse(event);
} catch (e) {
console.error('Error parsing data', e)
}
const yupAPI = new YupAPI({ PK: YUP_PK});
const fchubUtils = new FCHubUtils(FC_SIGNER, USER_FID);
const yupAPI = new YupAPI({ PK: YUP_PK });
const fchubUtils = new FCHubUtils(FC_SIGNER, USER_FID, HUB_URL, HUB_USER, HUB_PASS);
if(action === 'update') {
if (action === 'update') {
const VERSION = GithubEvent.inputs.version;
const FCONLY = GithubEvent.inputs.fconly;
const message = `Clear Wallet - New version ${VERSION} released! \n
ChangeLog: https://bit.ly/clw-cl \n
ChromeStore: https://bit.ly/clw-evm \n
`
if(ENABLED) {
await yupAPI.sendPost({
content: message,
platforms: ['twitter', 'threads', 'bsky', 'lens']
})
if (ENABLED) {
if (!FCONLY) {
await yupAPI.sendPost({
content: message,
platforms: ['twitter', 'threads', 'bsky', 'lens']
})
}
const fcPost = await fchubUtils.createFarcasterPost({
content: message,
})
const fcPostHash = Buffer.from(fcPost).toString('hex');
if(fcPostHash) {
if (fcPostHash) {
await new Promise((resolve) => setTimeout(resolve, 3000));
const launchCasterMessage = `@launch`
await fchubUtils.createFarcasterPost({ content: launchCasterMessage, replyTo: {
hash: fcPostHash,
fid: String(USER_FID)
} })
await fchubUtils.createFarcasterPost({
content: launchCasterMessage, replyTo: {
hash: fcPostHash,
fid: String(USER_FID)
}
})
}
} else {
console.log('No action required')
}
} else if(action === 'push') {
if(ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:')) {
} else if (action === 'push') {
if (ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:') && !GithubEvent?.head_commit?.message.includes('!')) {
const commiter = GithubEvent?.head_commit?.author.username || GithubEvent?.head_commit?.committer?.username || ''
const message = `Github ClearWallet new repo commit!\n
ChromeStore: https://bit.ly/clw-evm \n
Commit: ${GithubEvent.head_commit.url}
${ commiter ? `By: ${commiter}` : ''}
Commit: ${GithubEvent.head_commit.url} \n
${commiter ? `By: ${commiter}` : ''}
`;
await yupAPI.sendPost({
content: message,
platforms: ['twitter', 'threads', 'bsky', 'lens']
@ -104,11 +116,11 @@ const main = async () => {
await fchubUtils.createFarcasterPost({
content: message,
})
} else {
} else {
console.log('No action required')
}
}
}
console.log('Workflow executed successfully');
}