Skip to content

Commit

Permalink
Use action repository install.sh instead of downlaoding it
Browse files Browse the repository at this point in the history
  • Loading branch information
dloez committed Feb 11, 2024
1 parent ae529fe commit 5324444
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 43 deletions.
34 changes: 13 additions & 21 deletions action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80237,6 +80237,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799));
const path = __importStar(__nccwpck_require__(1017));
function getGitConfigProperty(propertyName) {
return __awaiter(this, void 0, void 0, function* () {
const { stdout, stderr } = yield exec.getExecOutput('git', [
Expand Down Expand Up @@ -80271,29 +80272,20 @@ function getActionRef() {
return '0.10.0';
});
}
function windowsDownload(scriptUrl, actionRef) {
function linuxMacInstall(actionRef) {
return __awaiter(this, void 0, void 0, function* () {
const { stdout, stderr } = yield exec.getExecOutput('powershell', []);
const rootActionDir = path.dirname(__dirname);
const { exitCode, stderr } = yield exec.getExecOutput('sh', ['install.sh', actionRef], {
cwd: rootActionDir
});
if (exitCode !== 0) {
core.setFailed(`Failed to install tag-track: ${stderr}`);
}
});
}
function linuxMacDownload(scriptUrl, actionRef) {
function windowsInstall(actionRef) {
return __awaiter(this, void 0, void 0, function* () {
const { stderr: stderrCurl } = yield exec.getExecOutput('curl', [scriptUrl]);
if (stderrCurl) {
core.setFailed(`Failed to download tag-track: ${stderrCurl}`);
}
let { stderr: stderrSh } = yield exec.getExecOutput('sh', [
'install.sh',
actionRef
]);
if (stderrSh) {
core.setFailed(`Failed to download tag-track: ${stderrSh}`);
}
yield exec.getExecOutput('mkdir', ['-p', 'tag-track-bin']);
yield exec.getExecOutput('mv', [
`${process.env.HOME}/.tag-track/bin/tag-track`,
'./tag-track-bin/tag-track'
]);
core.setFailed('TBI');
});
}
function setupDownload() {
Expand All @@ -80306,10 +80298,10 @@ function setupDownload() {
if (!cacheHit) {
const scriptUrl = `https://raw.githubusercontent.com/${process.env.GITHUB_REPOSITORY}/${actionRef}/install.sh`;
if (runnerOS == 'windows') {
yield windowsDownload(scriptUrl, actionRef);
yield windowsInstall(actionRef);
}
else {
yield linuxMacDownload(scriptUrl, actionRef);
yield linuxMacInstall(actionRef);
}
yield cache.saveCache(['tag-track-bin'], cacheKey);
}
Expand Down
39 changes: 17 additions & 22 deletions action/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as cache from '@actions/cache'
import * as path from 'path'

async function getGitConfigProperty(propertyName: string): Promise<string> {
const {stdout, stderr} = await exec.getExecOutput('git', [
Expand Down Expand Up @@ -37,29 +38,23 @@ async function getActionRef(): Promise<string> {
return '0.10.0'
}

async function windowsDownload(scriptUrl: string, actionRef: string) {
const {stdout, stderr} = await exec.getExecOutput('powershell', [])
}
async function linuxMacInstall(actionRef: string) {
const rootActionDir = path.dirname(__dirname)
const {exitCode, stderr} = await exec.getExecOutput(
'sh',
['install.sh', actionRef],
{
cwd: rootActionDir
}
)

async function linuxMacDownload(scriptUrl: string, actionRef: string) {
const {stderr: stderrCurl} = await exec.getExecOutput('curl', [scriptUrl])
if (stderrCurl) {
core.setFailed(`Failed to download tag-track: ${stderrCurl}`)
}

let {stderr: stderrSh} = await exec.getExecOutput('sh', [
'install.sh',
actionRef
])
if (stderrSh) {
core.setFailed(`Failed to download tag-track: ${stderrSh}`)
if (exitCode !== 0) {
core.setFailed(`Failed to install tag-track: ${stderr}`)
}
}

await exec.getExecOutput('mkdir', ['-p', 'tag-track-bin'])
await exec.getExecOutput('mv', [
`${process.env.HOME}/.tag-track/bin/tag-track`,
'./tag-track-bin/tag-track'
])
async function windowsInstall(actionRef: string) {
core.setFailed('TBI')
}

async function setupDownload() {
Expand All @@ -73,9 +68,9 @@ async function setupDownload() {
const scriptUrl = `https://raw.githubusercontent.com/${process.env.GITHUB_REPOSITORY}/${actionRef}/install.sh`

if (runnerOS == 'windows') {
await windowsDownload(scriptUrl, actionRef)
await windowsInstall(actionRef)
} else {
await linuxMacDownload(scriptUrl, actionRef)
await linuxMacInstall(actionRef)
}

await cache.saveCache(['tag-track-bin'], cacheKey)
Expand Down

0 comments on commit 5324444

Please sign in to comment.