Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {getDownloadUrl} from '../src/utils'
import {CLI_CONFIG_REGISTRY} from '../src/main'
import * as os from 'os'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import * as fs from 'fs'
import * as yaml from 'js-yaml'
import {expect, test} from '@jest/globals'

test('gets download url to binary', async () => {
Expand Down Expand Up @@ -36,11 +39,17 @@ test('gets download url to latest version', async () => {
// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['RUNNER_TEMP'] = os.tmpdir()
process.env['INPUT_VERSION'] = '1.0.0'
const config = path.join(__dirname, '..', 'action.yml')
const action: any = yaml.load(fs.readFileSync(config, 'utf8'))
process.env['INPUT_VERSION'] = action.inputs.version.default
const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}
console.log(cp.execFileSync(np, [ip], options).toString())
const stdout = cp.execFileSync(np, [ip], options).toString()
console.log(stdout)
expect
.stringContaining(`::set-env name=${CLI_CONFIG_REGISTRY}::`)
.asymmetricMatch(stdout)
})
18 changes: 15 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.

14 changes: 14 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"semver": "^7.3.8"
},
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/node": "^16.11.47",
"@types/semver": "^7.3.13",
"@typescript-eslint/parser": "^5.49.0",
Expand All @@ -38,6 +39,7 @@
"eslint-plugin-github": "^4.6.0",
"eslint-plugin-jest": "^27.2.1",
"jest": "^28.1.3",
"js-yaml": "^4.1.0",
"prettier": "2.8.3",
"ts-jest": "^28.0.8",
"typescript": "^4.8.4"
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import gte from 'semver/functions/lt'
import gte from 'semver/functions/gte'
import {getDownloadUrl} from './utils'

export const CLI_CONFIG_REGISTRY = 'SUPABASE_INTERNAL_IMAGE_REGISTRY'

async function run(): Promise<void> {
try {
// Get version of tool to be installed
Expand All @@ -20,7 +22,7 @@ async function run(): Promise<void> {

// Use GHCR mirror by default
if (version.toLowerCase() === 'latest' || gte(version, '1.28.0')) {
core.exportVariable('SUPABASE_INTERNAL_IMAGE_REGISTRY', 'ghcr.io')
core.exportVariable(CLI_CONFIG_REGISTRY, 'ghcr.io')
}
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
Expand Down