Skip to content

Commit

Permalink
added fetch-external workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm committed Oct 2, 2023
1 parent ce8626a commit 0a7584c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/fetch-external.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Chaindata Fetch External

on:
# runs at `0 minutes past the hour, every 6 hours`, starting at midnight UTC
schedule:
- cron: '0 0/6 * * *'
# can be run manually from the `Actions` tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow pushing commits
permissions:
contents: write
id-token: write

concurrency:
# only run 1 job per branch/pr/etc at a time
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
publish:
name: 'Fetch externals and push changes to repo'
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Fetch external
run: pnpm fetch-external
- name: Commit changes
run: |
git config user.name github-actions
git config user.email [email protected]
git commit -am 'updated externals'
git push
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
# runs on each commit pushed to the `main` branch
push:
branches: [main]
# runs at `0 minutes past the hour, every 6 hours`, starting at midnight UTC
# runs at `30 minutes past the hour, every 6 hours`, starting at midnight UTC
schedule:
- cron: '0 0/6 * * *'
- cron: '30 0/6 * * *'
# can be run manually from the `Actions` tab
workflow_dispatch:

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"import-pjs-config": "node scripts/import-pjs-config.js",
"update": "pnpm run update-pjs && pnpm run import-pjs-config",
"typecheck": "tsc --noEmit",
"fetch-external": "tsx scripts/fetch-external.ts",
"build": "tsx scripts/build.ts",
"clean": "rm -rf dist"
},
Expand Down
12 changes: 12 additions & 0 deletions scripts/fetch-external.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import startCase from 'lodash/startCase'

import { doSomeThings } from './fetch-external/steps/doSomeThings'

const steps: Array<() => Promise<void>> = [doSomeThings]

for (const [index, executeStep] of steps.entries()) {
console.log(`Executing step ${index + 1}: ${startCase(executeStep.name)}`)
await executeStep()
}

process.exit(0)
17 changes: 17 additions & 0 deletions scripts/fetch-external/steps/doSomeThings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { writeFile } from 'node:fs/promises'

export const doSomeThings = async () => {
await writeFile(
'assets/test-pls-delete.svg',
`<svg viewBox="0 0 82 82" xmlns="http://www.w3.org/2000/svg">
<rect width="82" height="82" rx="12" fill="#d5ff5c" />
<path
d="M62.571 45.425c-1.03 1.03-2.822.563-3.431-.763a1.982 1.982 0 0 1-.185-.829V20.989a5.003 5.003 0 0 0-10.005 0v11.562c0 .994-1.017 1.669-1.967 1.37a1.454 1.454 0 0 1-1.032-1.367V13.987a5.003 5.003 0 0 0-10.005 0v18.568a1.454 1.454 0 0 1-1.034 1.367c-.949.3-1.968-.376-1.968-1.371V20.99a5.003 5.003 0 0 0-10.005 0v22.853c0 .282-.064.556-.182.814-.596 1.294-2.346 1.747-3.355.74l-1.861-1.861a5.002 5.002 0 0 0-7.075 7.074l14.706 14.707a19.976 19.976 0 0 0 15.774 7.697c6.143 0 11.638-2.767 15.31-7.124l15.28-15.28a5.002 5.002 0 0 0-7.074-7.074zM40.945 65.01c8.84 0 16.007-10.005 16.007-10.005s-7.166-10.004-16.007-10.004-16.007 10.004-16.007 10.004S32.105 65.01 40.945 65.01z"
clip-rule="evenodd"
fill="#fd4848"
fill-rule="evenodd"
/>
<path d="M46.949 55.005a6.003 6.003 0 1 1-12.006 0 6.003 6.003 0 0 1 12.006 0z" fill="#fd4848" />
</svg>`
)
}

0 comments on commit 0a7584c

Please sign in to comment.