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

Add job summaries #398

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 15 additions & 0 deletions .github/workflows/test-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,18 @@ jobs:
- name: Compate files2
run: cmp --silent upload_action.yaml ./action.yaml

test-empty-folder:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'production' }}
name: A job that try to push an empty folder
steps:
- uses: actions/checkout@v3
- run: mkdir -p artifacts
- name: Push all files
uses: ./
with:
url: ${{ vars.ARTIFACTS_URL }}
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: ./artifacts
method: upload
37 changes: 33 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.

32 changes: 28 additions & 4 deletions src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,34 @@ export async function setOutputs(name: string, url: string): Promise<void> {
core.setOutput('link', `${url}/builds/${name}`)
}

export async function setNotice(name: string, url: string): Promise<void> {
core.info(
`::notice:: Your artifacts has been uploaded here: ${url}/builds/${name}`
)
export async function setNotice(name: string, url: string, requests?: string[]): Promise<void> {
if (core.summary.isEmptyBuffer() === true) {
await core.summary.addHeading('Artifacts').write()
}
await core.summary
.addHeading(`${github.context.action}`, 2)
.addRaw('Artifacts has been uploaded to the following location:')
.addLink(`${name}`, `${url}/builds/${name}`)
.write()
// if requests is defined, we add a list with the directories
// that have been created within requests.
// first we retrieve the directories
if (requests !== undefined) {

const directories: string[] = []

for (const file of requests) {
const dirname = path.basename(path.dirname(file))
if (directories.includes(dirname) === false) {
directories.push(dirname)
}
}
// then we add the list
await core.summary.addHeading('Directories', 3).write()
for (const directory of directories) {
await core.summary.addRaw(`- [${directory}](${url}/builds/${name}/${directory})\n`).write()
}
}
}

export async function fileUpload(
Expand Down
7 changes: 6 additions & 1 deletion src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ export async function upload(inputs: InputsArtifacts): Promise<void> {
requests.push(file)
}

// if no files are found, log a warning and exit
if (requests.length === 0) {
core.warning(`No files found for the provided path: ${inputs.source}`)
return
}
await async.eachLimit(requests, 16, async (file: string, next) => {
core.info(`Uploading file: ${file}`)
try {
Expand All @@ -186,7 +191,7 @@ export async function upload(inputs: InputsArtifacts): Promise<void> {
core.info('All files are uploaded ')

await setOutputs(name, inputs.url)
await setNotice(name, inputs.url)
await setNotice(name, inputs.url, requests)
}

export async function get(inputs: InputsArtifacts): Promise<void> {
Expand Down
Loading