Skip to content

Commit

Permalink
Merge pull request #22 from radio4000/feat/use-env
Browse files Browse the repository at this point in the history
use env vars for supabase_{key,url} and also in actions
  • Loading branch information
4www authored Apr 18, 2024
2 parents cfc5c05 + 5ca67a2 commit 9f9a7c9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/deploy_static_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
VITE_SUPABASE_URL: '${{ env.SUPABASE_URL }}'
VITE_SUPABASE_KEY: '${{ env.SUPABASE_KEY }}'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
Expand All @@ -17,7 +21,7 @@ permissions:

# Allow one concurrent deployment
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: true

jobs:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/publish-to-npm-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
VITE_SUPABASE_URL: '${{ env.SUPABASE_URL }}'
VITE_SUPABASE_KEY: '${{ env.SUPABASE_KEY }}'

jobs:
publish:
runs-on: ubuntu-latest
Expand Down
28 changes: 18 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>@radio4000/sdk</title>
<link rel="icon" href="data:;base64,ivborw0kggo=">
<link rel="icon" href="data:;base64,ivborw0kggo=" />
</head>
<body>

<article>
<p>
Testing the <a href="https://github.com/radio4000/sdk">@radio4000/sdk</a>.
Try it out in the browser console under `window.sdk`.</p>
Testing the <a href="https://github.com/radio4000/sdk">@radio4000/sdk</a>. Try it out in the browser console
under `window.sdk`.
</p>
</article>

<ul id="channels"></ul>
Expand All @@ -35,8 +35,12 @@

// Fetch and render some channels to test.
const ul = document.querySelector('#channels')
sdk.channels.readChannels(100).then(response => {
sdk.channels.readChannels(100).then((response) => {
console.log(response)

if (!response?.data) {
return
}
for (const c of response.data) {
const li = document.createElement('li')
const input = document.createElement('input')
Expand All @@ -46,7 +50,7 @@
ul.appendChild(li)
}
// Testing it worked
sdk.channels.readChannel(response.data[0].slug).then(res => console.log(res))
sdk.channels.readChannel(response.data[0].slug).then((res) => console.log(res))
})

/**
Expand All @@ -59,7 +63,9 @@
async function sdkTest(slug, email, password) {
console.log('testing')

const {data: {user}} = await sdk.auth.signIn({email, password})
const {
data: {user},
} = await sdk.auth.signIn({email, password})

await sdk.channels.createChannel({name: 'Radio Test', slug: slug})

Expand All @@ -69,10 +75,13 @@

const {data: updatedChannel} = await sdk.channels.readChannel(slug)

console.log('same channel', channel.id === updatedChannel.id, )
console.log('same channel', channel.id === updatedChannel.id)
console.log('name field was updated', updatedChannel.name === 'updated')

const {data: track} = await sdk.tracks.createTrack(channel.id, {url: 'https://www.youtube.com/watch?v=dA55o_18a-g', title: 'My new track'})
const {data: track} = await sdk.tracks.createTrack(channel.id, {
url: 'https://www.youtube.com/watch?v=dA55o_18a-g',
title: 'My new track',
})

console.log('track was created', track.title === 'My new track')

Expand All @@ -83,6 +92,5 @@
</script>

<p>See the <a href="/docs">full documentation</a>.</p>

</body>
</html>
4 changes: 2 additions & 2 deletions package-lock.json

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

7 changes: 3 additions & 4 deletions src/sdk-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import {createClient} from '@supabase/supabase-js'
import {createSdk} from './create-sdk.js'

const supabase = createClient(
'https://myjhnqgfwqtcicnvcwcj.supabase.co',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTY0MTQxNTQ3MiwiZXhwIjoxOTU2OTkxNDcyfQ.gySR3Lv-m_CIj2Eyx6kfyOdwwMXEOFOgeHSjADqcM4Y'
)
const {VITE_SUPABASE_URL, VITE_SUPABASE_KEY} = import.meta.env

const supabase = createClient(VITE_SUPABASE_URL, VITE_SUPABASE_KEY)

/**
* The default Radio4000 SDK connects to the main Supabase project.
Expand Down

0 comments on commit 9f9a7c9

Please sign in to comment.