Skip to content

Commit

Permalink
feat(auto-pr): update setup-node for auto create assets-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
49659410+tx0c committed Apr 24, 2024
1 parent 530f8d9 commit c26d91b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/checkin-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install Dependencies
run: npm install @aws-sdk/client-s3 ## the only dependency for ./bin/sync-up-latest-round.mjs
Expand All @@ -26,7 +25,8 @@ jobs:

- uses: gr2m/create-or-update-pull-request-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BILLBOARD_GITHUB_TOKEN }}
with:
path: "./public/static"
path: "public/static"
title: check in latest round Assets from 'Create or Update Request' action

10 changes: 6 additions & 4 deletions bin/sync-up-latest-round.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ const client = new S3Client() // use credentials from environment

const AssetsDir = './public/static'

export const main = async () => {
export const main = async (branch = 'prod') => {
const controller = new AbortController()
const { signal } = controller
const developPrefix = branch !== 'prod' ? 'web-develop/' : ''

try {
// The Body object also has 'transformToByteArray' and 'transformToWebStream' methods.
const roundsContent = await (
await client.send(
new GetObjectCommand({
Bucket: 'matters-billboard',
Key: 'rounds/rounds.json',
Key: `${developPrefix}rounds/rounds.json`,
})
)
).Body.transformToString()
Expand Down Expand Up @@ -47,7 +48,7 @@ export const main = async () => {
await client.send(
new GetObjectCommand({
Bucket: 'matters-billboard',
Key: `rounds/${lastRound.dirpath}/${file}`,
Key: `${developPrefix}rounds/${lastRound.dirpath}/${file}`,
})
)
).Body.transformToString()
Expand All @@ -68,4 +69,5 @@ export const main = async () => {
}
}

await main()
// console.log('run with argv:', process.argv)
await main(process.argv?.[2] || 'prod')

0 comments on commit c26d91b

Please sign in to comment.