Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'workflow' input optional #178

Merged
merged 1 commit into from
Jul 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Let's suppose you have a workflow with a job in it that at the end uploads an ar
# Required, if artifact is from a different repo
# Required, if repo is private a Personal Access Token with `repo` scope is needed
github_token: ${{secrets.GITHUB_TOKEN}}
# Required, workflow file name or ID
# Optional, workflow file name or ID
# If not specified, will be inferred from run_id (if run_id is specified), or will be the current workflow
workflow: workflow_name.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion:
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ inputs:
required: false
default: ${{github.token}}
workflow:
description: Workflow name
required: true
description: |
Workflow name.

If not specified, will be inferred from run_id (if run_id is specified), or will be the current workflow
required: false
workflow_conclusion:
description: |
Wanted status or conclusion to search for in recent runs
Expand Down
14 changes: 12 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ function inform(key, val) {
async function main() {
try {
const token = core.getInput("github_token", { required: true })
const workflow = core.getInput("workflow", { required: true })
const [owner, repo] = core.getInput("repo", { required: true }).split("/")
const path = core.getInput("path", { required: true })
const name = core.getInput("name")
const skipUnpack = core.getInput("skip_unpack")
let workflow = core.getInput("workflow")
let workflowConclusion = core.getInput("workflow_conclusion")
let pr = core.getInput("pr")
let commit = core.getInput("commit")
Expand All @@ -30,10 +30,20 @@ async function main() {

const client = github.getOctokit(token)

core.info(`==> Repository: ${owner}/${repo}`)
core.info(`==> Artifact name: ${name}`)
core.info(`==> Local path: ${path}`)

if (!workflow) {
const run = await client.rest.actions.getWorkflowRun({
owner: owner,
repo: repo,
run_id: runID || github.context.runId,
});
workflow = run.data.workflow_id
}

core.info(`==> Workflow name: ${workflow}`)
core.info(`==> Repository: ${owner}/${repo}`)
core.info(`==> Workflow conclusion: ${workflowConclusion}`)

const uniqueInputSets = [
Expand Down