Skip to content

Commit

Permalink
chore: fix linting error and rebuild action
Browse files Browse the repository at this point in the history
  • Loading branch information
abannachGrafana committed Sep 19, 2023
1 parent 38dff92 commit ccf9b52
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
32 changes: 28 additions & 4 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.

24 changes: 16 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as github from '@actions/github'
import fs from 'fs'
import path from 'path'
import {Tree} from './types'
import { Context } from '@actions/github/lib/context'
import {Context} from '@actions/github/lib/context'

async function getTrimmedOutput(
command: string,
Expand Down Expand Up @@ -36,16 +36,21 @@ async function getTrimmedOutputArray(
.filter(f => f !== '')
}

async function getRepoFromCheckout(): Promise<Context["repo"]> {
const remoteOriginUrl = await getTrimmedOutput('git', ['remote','get-url','origin'])
async function getRepoFromCheckout(): Promise<Context['repo']> {
const remoteOriginUrl = await getTrimmedOutput('git', [
'remote',
'get-url',
'origin'
])

core.debug(`remoteOriginUrl: ${remoteOriginUrl}`)

const githubRepoRegex = /^(?:https:\/\/github\.com\/|git@github\.com:)([^\/]+)\/([^\/]+?)(?:\.git)?$/;
const githubRepoRegex =
/^(?:https:\/\/github\.com\/|git@github\.com:)([^/]+)\/([^/]+?)(?:\.git)?$/

const match = remoteOriginUrl.match(githubRepoRegex);
const match = remoteOriginUrl.match(githubRepoRegex)

if(match) {
if (match) {
const repo = {
owner: match[1],
repo: match[2]
Expand All @@ -62,10 +67,13 @@ async function run(): Promise<void> {
const stageAllFiles = core.getInput('stage-all-files')
const token = core.getInput('token')
const useCheckoutRepo = core.getInput('use-checkout-repo')

const octokit = github.getOctokit(token)

const repo = useCheckoutRepo === 'true' ? await getRepoFromCheckout() : github.context.repo
const repo =
useCheckoutRepo === 'true'
? await getRepoFromCheckout()
: github.context.repo

// Get the root directory for the repository
const rootDir = await getTrimmedOutput('git', [
Expand Down

0 comments on commit ccf9b52

Please sign in to comment.