-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: ~publish test results into a shields.io endpoint json file | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
BADGE_FILES: | ||
type: string | ||
description: 'Name/wildcard pattern for shields.io endpoint JSON' | ||
required: true | ||
# outputs: | ||
# GIST_ID: | ||
# description: 'Id of the GitHub Gist that hosts all endpoint JSON files' | ||
# value: ${{ jobs.publish.outputs.STATUS }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-22.04 | ||
# outputs: | ||
# STATUS: ${{ steps.script.outputs.STATUS }} | ||
steps: | ||
- name: Download artifacts specified by input | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Update status badge file in gist | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.NVJAX_GIST_TOKEN }} | ||
script: | | ||
const fs = require('fs').promises; | ||
const filesInDirectory = await fs.readdir('.'); | ||
const matchingFiles = filesInDirectory.filter( | ||
filename => filename.includes(${{ inputs.BADGE_FILES }}) | ||
); | ||
const filesToCreate = await Promise.all( | ||
matchingFiles.map( | ||
async filename => { | ||
const content = await fs.readFile(filename, 'utf8'); | ||
return [filename, { content }]; | ||
} | ||
) | ||
); | ||
const currentDateTime = new Date().toISOString(); | ||
const gistDescription = | ||
`Badge endpoint files from Workflow: ${{ github.workflow }}, ` + | ||
`Run ID: ${{ github.run_id }}, ` + | ||
`Repository: ${{ github.repository }}, ` + | ||
`Event: ${{ github.event_name }}, ` + | ||
`Created: ${currentDateTime}`; | ||
gist = await github.rest.gists.create({ | ||
description: gistDescription, | ||
public: false, | ||
files: Object.fromEntries(filesToCreate) | ||
}); | ||
console.log(gist) | ||
// return gist.data.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.