Skip to content

Commit

Permalink
fix: fixed input
Browse files Browse the repository at this point in the history
  • Loading branch information
saurav0705 committed Mar 24, 2024
1 parent b76a376 commit 8bedd18
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ The GitHub token used to authenticate API requests. You can use the `{{ secrets.
- Description: This setting defines the pattern against which checks will be applied.
- Value: `/file/pattern` represents the picomatch expression pattern used for matching.

### `ARTIFACT_RETENTION_DAYS`

This is used to set artifact retention days while logging a successful run and will be consumed when `UPLOAD_KEYS` is given.

## Outputs

This Return a `status` object in which the following are present
Expand Down
4 changes: 1 addition & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ inputs:
UPLOAD:
description: This is required to publish the successful sha to repo varaible
required: false
default: |
key: ''
retentionDays : 30
default: ''
CONFIG:
required: true
description: |
Expand Down
16 changes: 11 additions & 5 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.

4 changes: 2 additions & 2 deletions src/get-upload-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ type TUploadConfig = {

export const getUploadConfig = (config: string): TUploadConfig => {
const _config = checkForFileOrLoadYml(config)
if (_config.name?.length) {
if (!_config.key?.length) {
throw new Error(`name is required to upload artifact`)
}
const initialConfig: TUploadConfig = {
key: _config.name,
key: _config.key,
retentionDays: 30
}

Expand Down
20 changes: 15 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@ import {getConfig} from './get-config'
import {getUploadConfig} from './get-upload-config'

const uploadFlow = async (input: string) => {
startGroup(`Starting Upload Flow...`)
info(`GITHUB CONFIG => ${JSON.stringify(github.CONFIG, null, 2)}`)
const {key, retentionDays} = getUploadConfig(input)
info(
`Uploading Artifact for ${JSON.stringify(
{input, key, retentionDays},
null,
2
)}`
)
await artifact.uploadArtifact(key, github.CONFIG.sha, retentionDays)
endGroup()
return
}

const checkFlow = async (config: string) => {
startGroup(`Started Check Flow...`)
info(`GITHUB CONFIG => ${JSON.stringify(github.CONFIG, null, 2)}`)
const setOutputResponse = (response: ArtifactFinalResponseStatus[]): void => {
for (const resp of response) {
setOutput(resp.suppliedKey, resp)
Expand Down Expand Up @@ -72,11 +84,13 @@ const checkFlow = async (config: string) => {

endGroup()

startGroup(`Posting PR Comment`)
// post a message summary of action if not disabled
await postCommentOnPrWithDetails(
artifactValueWithShaAndFileDiffWithShouldRunStatus,
comment
)
endGroup()

// set output
setOutputResponse(artifactValueWithShaAndFileDiffWithShouldRunStatus)
Expand All @@ -94,11 +108,7 @@ async function run(): Promise<void> {
sha: context.payload.pull_request?.head.sha ?? ''
})

startGroup(`Initiating configs for github and input...`)

info(`GITHUB CONFIG => ${JSON.stringify(github.CONFIG, null, 2)}`)

if (UPLOAD) {
if (UPLOAD?.length) {
await uploadFlow(UPLOAD)
return
}
Expand Down

0 comments on commit 8bedd18

Please sign in to comment.