mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2024-12-19 00:00:45 +00:00
chore: add CI workflow pkg
This commit is contained in:
parent
86bdfd136b
commit
7eab21188b
37
.github/bun-workflow.yaml
vendored
Normal file
37
.github/bun-workflow.yaml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Not supported due to compatibility issues with Bun Http2 stdlib
|
||||||
|
name: Bun Main Workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-bun-script:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: CI
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
version: '1.1.18'
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: bun install
|
||||||
|
|
||||||
|
- name: Run Bun Script - Update
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
run: bun run index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' update
|
||||||
|
|
||||||
|
- name: Run Bun Script - Push
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: bun run index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' push
|
38
.github/node-workflow.yaml
vendored
Normal file
38
.github/node-workflow.yaml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Not supported due to compatibility issues with Bun Http2 stdlib
|
||||||
|
name: Node Main Workflow
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-node-script:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: CI
|
||||||
|
steps:
|
||||||
|
- name: Checkout Action
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node Action
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
|
- name: Run Node Script - Update
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
run: yarn tsx index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' update
|
||||||
|
|
||||||
|
- name: Run Node Script - Push
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: yarn tsx index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' push
|
43
.github/workflows/main.yaml
vendored
43
.github/workflows/main.yaml
vendored
@ -1,32 +1,37 @@
|
|||||||
name: Bun Script Execution
|
# Not supported due to compatibility issues with Bun Http2 stdlib
|
||||||
|
name: Bun Main Workflow
|
||||||
|
|
||||||
on:
|
on:
|
||||||
#push: # Trigger on push events to master branch (you can adjust this trigger)
|
push:
|
||||||
workflow_dispatch: # Trigger on manual workflow dispatch
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version'
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-bun-script:
|
run-bun-script:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: CI
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
version: '1.1.18'
|
||||||
|
|
||||||
- name: Get Parameters (for push event)
|
- name: Install Dependencies
|
||||||
if: github.event_name == 'push'
|
run: bun install
|
||||||
run: |
|
|
||||||
# No parameters are automatically provided on push events
|
- name: Run Bun Script - Update
|
||||||
echo "No parameters provided on push event."
|
|
||||||
|
|
||||||
- name: Get Parameters (for manual trigger)
|
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
run: |
|
run: bun run index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' update
|
||||||
PARAM_VALUE_1=${{ github.event.inputs.param1 }}
|
|
||||||
PARAM_VALUE_2=${{ github.event.inputs.param2 }}
|
|
||||||
# ... add more parameter retrieval as needed
|
|
||||||
# Use empty strings if parameters are not provided
|
|
||||||
|
|
||||||
- name: Run Bun Script
|
- name: Run Bun Script - Push
|
||||||
run: bun run index.ts --param1 $PARAM_VALUE_1 --param2 $PARAM_VALUE_2
|
if: github.event_name == 'push'
|
||||||
# Adjust the command based on your parameter names and flags
|
run: bun run index.ts '${{ toJSON(secrets) }}' '${{ toJSON(github.event) }}' push
|
||||||
|
16
CI/README.md
16
CI/README.md
@ -1,15 +1,3 @@
|
|||||||
# ci
|
# CI
|
||||||
|
|
||||||
To install dependencies:
|
Pacakge to run CI/CD pipelines for the project.
|
||||||
|
|
||||||
```bash
|
|
||||||
bun install
|
|
||||||
```
|
|
||||||
|
|
||||||
To run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bun run index.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
This project was created using `bun init` in bun v1.1.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
||||||
|
BIN
CI/bun.lockb
BIN
CI/bun.lockb
Binary file not shown.
100
CI/index.ts
100
CI/index.ts
@ -1,23 +1,105 @@
|
|||||||
import { YupAPI } from 'yup-api-interact'
|
import { YupAPI } from 'yup-api-interact'
|
||||||
|
import { FCHubUtils } from 'farcaster-hub-utils'
|
||||||
|
|
||||||
|
const args = Bun.argv.slice(2);
|
||||||
|
|
||||||
const args = Bun.argv.slice(3);
|
const secrets = args[0]
|
||||||
|
const event = args[1]
|
||||||
const secrets = JSON.parse(args[0]);
|
|
||||||
const githubEvvent = JSON.parse(args[1]);
|
|
||||||
const action = args[2]
|
const action = args[2]
|
||||||
|
|
||||||
|
type TGithubEvent = {
|
||||||
|
inputs: {
|
||||||
|
version: string
|
||||||
|
},
|
||||||
|
forced: boolean,
|
||||||
|
repository: {
|
||||||
|
name: string,
|
||||||
|
full_name: string,
|
||||||
|
html_url: string,
|
||||||
|
description: string
|
||||||
|
},
|
||||||
|
head_commit: {
|
||||||
|
id: string,
|
||||||
|
message: string,
|
||||||
|
timestamp: string,
|
||||||
|
url: string,
|
||||||
|
author: {
|
||||||
|
name: string,
|
||||||
|
email: string,
|
||||||
|
username: string
|
||||||
|
},
|
||||||
|
committer: {
|
||||||
|
name: string,
|
||||||
|
email: string,
|
||||||
|
username: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const YUP_PK = secrets.YUP_PK;
|
const ENABLED = true;
|
||||||
|
let YUP_PK = '';
|
||||||
|
let FC_SIGNER = ''
|
||||||
|
let GithubEvent: TGithubEvent = {} as TGithubEvent;
|
||||||
|
const USER_FID = 709233;
|
||||||
|
|
||||||
const api = new YupAPI({ PK: YUP_PK, token: '' });
|
console.log('Anouncement enabled status: ', '[ ', ENABLED, ' ]');
|
||||||
|
|
||||||
if(action === 'commit') {
|
try {
|
||||||
console.log('Announcing commit')
|
const parsedSecrets = JSON.parse(secrets);
|
||||||
console.log(secrets, githubEvvent)
|
YUP_PK = parsedSecrets.YUP_PK;
|
||||||
|
FC_SIGNER = parsedSecrets.FC_SIGNER;
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(action === 'update') {
|
||||||
|
const VERSION = GithubEvent.inputs.version;
|
||||||
|
const message = `Github ClearWallet new version ${VERSION} has been released!\n
|
||||||
|
ChromeStore: https://bit.ly/clw-evm \n
|
||||||
|
Github: https://github.com/andrei0x309/clear-wallet
|
||||||
|
`;
|
||||||
|
|
||||||
|
if(ENABLED) {
|
||||||
|
await yupAPI.sendPost({
|
||||||
|
content: message,
|
||||||
|
platforms: ['twitter', 'threads', 'bsky', 'lens']
|
||||||
|
})
|
||||||
|
await fchubUtils.createFarcasterPost({
|
||||||
|
content: message,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('No action required')
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(action === 'push') {
|
||||||
|
if(ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:')) {
|
||||||
|
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}` : ''}
|
||||||
|
`;
|
||||||
|
|
||||||
|
await yupAPI.sendPost({
|
||||||
|
content: message,
|
||||||
|
platforms: ['twitter', 'threads', 'bsky', 'lens']
|
||||||
|
})
|
||||||
|
|
||||||
|
await fchubUtils.createFarcasterPost({
|
||||||
|
content: message,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('No action required')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Workflow executed successfully');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(console.error);
|
main().catch(console.error);
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"yup-api-interact": "^0.1.4",
|
"farcaster-hub-utils": "^0.1.7",
|
||||||
"farcaster-hub-utils": "https://github.com/andrei0x309/farcaster-hub-utils#main"
|
"yup-api-interact": "^0.1.6"
|
||||||
}
|
},
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user