Skip to content

Commit

Permalink
feat: filename join to destiny (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelramos authored May 14, 2022
1 parent 8f463b0 commit 35059db
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
check-dist:
runs-on: ubuntu-latest
runs-on: macOS-latest

steps:
- uses: actions/checkout@v2
Expand Down
19 changes: 17 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import {walk} from '../src/utils'
import {expect, test} from '@jest/globals'
import {resolve, join, basename} from 'path'

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
expect(true).toBeTruthy();
test('Should walk directory', async () => {
const root = resolve(join(__dirname, '../src'))

const files = await walk(root)

expect(files.length > 0).toBeTruthy()
})

test('Should retrive filenames', async () => {
const root = resolve(join(__dirname, '../src'))

const files = await walk(root)
const filenames = files.map(file => basename(file))

expect(filenames.length > 0).toBeTruthy()
})
12 changes: 9 additions & 3 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-console */
import * as core from '@actions/core'
import {basename, join} from 'path'
import {fileBuffer, walk} from './utils'
import {createClient} from '@supabase/supabase-js'

Expand All @@ -22,19 +24,26 @@ async function run(): Promise<void> {
const upload = async (): Promise<void> => {
for (const asset of assets) {
const file = await fileBuffer(asset)

await supabase.storage.from(bucket).upload(destiny, file, {
cacheControl: '3600',
upsert: false
})

core.debug(`File: ${file} uploaded to bucket: ${bucket}/${destiny}`)
const filename = basename(asset)

await supabase.storage
.from(bucket)
.upload(join(destiny, filename), file, {
cacheControl: '3600',
upsert: false
})

core.debug(`File: ${filename} uploaded to bucket: ${bucket}/${destiny}`)
console.log(
`File: ${filename} uploaded to bucket: ${bucket}/${destiny}`
)
}
}

await upload()

core.debug(`Files uploaded succefull to bucket: ${bucket}`)
console.log(`Files uploaded succefull to bucket: ${bucket}`)
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}
Expand Down

0 comments on commit 35059db

Please sign in to comment.