Skip to content

Commit

Permalink
feat(sync): convert sync into a CLI to allow extendability (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxingloh authored Jan 29, 2024
1 parent c64dab1 commit 3b9f085
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
branches:
- main
paths:
- .github/workflows/sync-trustwallet-assets.yml
- workspace/sync-trustwallet-assets/**/*
- .github/workflows/sync.yml
- workspace/sync/**/*
schedule:
- cron: '0 0 * * *'

Expand All @@ -22,6 +22,11 @@ jobs:
main:
runs-on: ubuntu-latest
environment: FRONTMATTER_BOT
strategy:
fail-fast: false
matrix:
repo:
- trustwallet/assets
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

Expand All @@ -33,14 +38,21 @@ jobs:

- run: pnpm install --frozen-lockfile

- run: pnpm turbo run build
working-directory: workspace/sync

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: workspace/sync-trustwallet-assets/repo
repository: trustwallet/assets
# PLEASE be aware that this is a security risk when you allow untrusted repositories to be checked out.
# While `pnpm run sync` is executed such that we're only reading files which pose no security risk,
# it's nonetheless possible through other means to execute arbitrary code
# when you attempt to do "TOO MUCH" outside its intended use case.
path: workspace/sync/repo
repository: ${{ matrix.repo }}
ref: master

- run: pnpm turbo run sync
working-directory: workspace/sync-trustwallet-assets
- run: pnpm run sync ${{ matrix.repo }}
working-directory: workspace/sync

- id: app
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
Expand All @@ -51,13 +63,13 @@ jobs:
- uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
with:
token: ${{ steps.app.outputs.token }}
commit-message: 'chore(sync): trustwallet/assets'
title: 'chore(sync): trustwallet/assets'
commit-message: 'chore(sync): ${{ matrix.repo }}'
title: 'chore(sync): ${{ matrix.repo }}'
committer: Frontmatter Bot <[email protected]>
author: Frontmatter Bot <[email protected]>
body: |
#### What this PR does / why we need it:
Sync latest changes from `trustwallet/assets` repository.
Sync latest changes from `${{ matrix.repo }}` repository using `@workspace/sync`.
branch: sync/trustwallet/assets
branch: sync/${{ matrix.repo }}
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
2 changes: 1 addition & 1 deletion .idea/frontmatter.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "turbo run clean",
"format": "prettier --write .",
"lint": "turbo run lint -- --fix",
"prepare": "husky install",
"prepare": "husky",
"test": "turbo run test"
},
"lint-staged": {
Expand All @@ -27,7 +27,7 @@
"turbo": "^1.11.3",
"typescript": "5.3.3"
},
"packageManager": "pnpm@8.14.3",
"packageManager": "pnpm@8.15.0",
"engines": {
"node": "^18 <19",
"pnpm": "^8 <9"
Expand Down
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion workspace/sync-trustwallet-assets/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions workspace/sync-trustwallet-assets/src/gitlog.ts

This file was deleted.

59 changes: 0 additions & 59 deletions workspace/sync-trustwallet-assets/src/index.ts

This file was deleted.

118 changes: 0 additions & 118 deletions workspace/sync-trustwallet-assets/src/sync.ts

This file was deleted.

9 changes: 0 additions & 9 deletions workspace/sync-trustwallet-assets/turbo.json

This file was deleted.

1 change: 1 addition & 0 deletions workspace/sync/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/repo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@workspace/sync-trustwallet-assets",
"name": "@workspace/sync",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "tsc --project tsconfig.build.json",
"clean": "rm -rf dist",
"lint": "eslint .",
"sync": "node dist/index.js"
"sync": "node dist/bin.js"
},
"lint-staged": {
"*": [
Expand All @@ -18,6 +18,7 @@
]
},
"dependencies": {
"clipanion": "3.2.1",
"yaml": "^2.3.4"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 3b9f085

Please sign in to comment.