Add gist upload output action (#212)
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
filename, optimize, verify,
|
filename, optimize, verify,
|
||||||
debug, "debug.flags":dflags, "use.mocked.data":mocked, dryrun,
|
debug, "debug.flags":dflags, "use.mocked.data":mocked, dryrun,
|
||||||
"plugins.errors.fatal":die,
|
"plugins.errors.fatal":die,
|
||||||
"committer.token":_token, "committer.branch":_branch, "committer.message":_message,
|
"committer.token":_token, "committer.branch":_branch, "committer.message":_message, "committer.gist":_gist,
|
||||||
"use.prebuilt.image":_image,
|
"use.prebuilt.image":_image,
|
||||||
retries, "retries.delay":retries_delay,
|
retries, "retries.delay":retries_delay,
|
||||||
"output.action":_action,
|
"output.action":_action,
|
||||||
@@ -127,6 +127,7 @@
|
|||||||
if (!dryrun) {
|
if (!dryrun) {
|
||||||
//Compute committer informations
|
//Compute committer informations
|
||||||
committer.token = _token || token
|
committer.token = _token || token
|
||||||
|
committer.gist = _action === "gist" ? _gist : null
|
||||||
committer.commit = true
|
committer.commit = true
|
||||||
committer.message = _message.replace(/[$][{]filename[}]/g, filename)
|
committer.message = _message.replace(/[$][{]filename[}]/g, filename)
|
||||||
committer.pr = /^pull-request/.test(_action)
|
committer.pr = /^pull-request/.test(_action)
|
||||||
@@ -138,6 +139,9 @@
|
|||||||
throw new Error("You must provide a valid GitHub token to commit your metrics")
|
throw new Error("You must provide a valid GitHub token to commit your metrics")
|
||||||
info("Committer branch", committer.branch)
|
info("Committer branch", committer.branch)
|
||||||
info("Committer head branch", committer.head)
|
info("Committer head branch", committer.head)
|
||||||
|
//Gist
|
||||||
|
if (committer.gist)
|
||||||
|
info("Committer Gist id", committer.gist)
|
||||||
//Instantiate API for committer
|
//Instantiate API for committer
|
||||||
committer.rest = github.getOctokit(committer.token)
|
committer.rest = github.getOctokit(committer.token)
|
||||||
info("Committer REST API", "ok")
|
info("Committer REST API", "ok")
|
||||||
@@ -279,6 +283,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Upload to gist (this is done as user since committer_token may not have gist rights)
|
||||||
|
if (committer.gist) {
|
||||||
|
await rest.gists.update({gist_id:committer.gist, files:{[filename]:{content:rendered}}})
|
||||||
|
info(`Upload to gist ${committer.gist}`, "ok")
|
||||||
|
committer.commit = false
|
||||||
|
}
|
||||||
|
|
||||||
//Commit metrics
|
//Commit metrics
|
||||||
if (committer.commit) {
|
if (committer.commit) {
|
||||||
await committer.rest.repos.createOrUpdateFileContents({
|
await committer.rest.repos.createOrUpdateFileContents({
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ Specify a single value to apply it to both height and with, and two values to us
|
|||||||
config_padding: 6%, 10% # 6% width padding, 10% height padding
|
config_padding: 6%, 10% # 6% width padding, 10% height padding
|
||||||
```
|
```
|
||||||
|
|
||||||
### 🧶 Using commits, pull requests or manual review to handle metrics output
|
### 🧶 Using commits, pull requests, manual reviews or gists to handle metrics output
|
||||||
|
|
||||||
It is possible to configure output behaviour using `output_action` option, which can be set to:
|
It is possible to configure output behaviour using `output_action` option, which can be set to:
|
||||||
- `none`, where output will be generated in `/rendered/${filename}` without being pushed
|
- `none`, where output will be generated in `/rendered/${filename}` without being pushed
|
||||||
@@ -163,6 +163,8 @@ It is possible to configure output behaviour using `output_action` option, which
|
|||||||
- By appending either `-merge`, `-squash` or `-rebase`, pull request will be automatically merged with given method
|
- By appending either `-merge`, `-squash` or `-rebase`, pull request will be automatically merged with given method
|
||||||
- This method is useful to combine all editions of a single run with multiples metrics steps into a single commit on targetted branch
|
- This method is useful to combine all editions of a single run with multiples metrics steps into a single commit on targetted branch
|
||||||
- If you choose to manually merge pull requests, be sure to disable `push:` triggers on your workflow, as it'll count as your own commit
|
- If you choose to manually merge pull requests, be sure to disable `push:` triggers on your workflow, as it'll count as your own commit
|
||||||
|
- `gist`, where output will be stored an already existing gist
|
||||||
|
- To use this feature, a `gists` scope must be granted to your `token` and `committer_gist` identifier must be provided
|
||||||
|
|
||||||
#### ℹ️ Examples workflows
|
#### ℹ️ Examples workflows
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ inputs:
|
|||||||
type: string
|
type: string
|
||||||
default: Update ${filename} - [Skip GitHub Action]
|
default: Update ${filename} - [Skip GitHub Action]
|
||||||
|
|
||||||
|
# Instead of saving metrics to a repository, it's possible to save them to a gist to avoid "commits pollution"
|
||||||
|
# Gist must be created prior and you must pass its identifier in the following option
|
||||||
|
# Set "gist" in "output_action" to use this option
|
||||||
|
committer_gist:
|
||||||
|
description: Gist used to store metrics
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
|
||||||
# Rendered metrics output path, relative to repository's root
|
# Rendered metrics output path, relative to repository's root
|
||||||
filename:
|
filename:
|
||||||
description: Rendered metrics output path
|
description: Rendered metrics output path
|
||||||
@@ -83,6 +91,7 @@ inputs:
|
|||||||
- pull-request-merge # Same as "pull-request" and additionaly merge pull request
|
- pull-request-merge # Same as "pull-request" and additionaly merge pull request
|
||||||
- pull-request-squash # Same as "pull-request" and additionaly squash and merge pull request
|
- pull-request-squash # Same as "pull-request" and additionaly squash and merge pull request
|
||||||
- pull-request-rebase # Same as "pull-request" and additionaly rebase and merge pull request
|
- pull-request-rebase # Same as "pull-request" and additionaly rebase and merge pull request
|
||||||
|
- gist # Save output to "committer_gist"
|
||||||
|
|
||||||
# Optimize SVG image to reduce its filesize
|
# Optimize SVG image to reduce its filesize
|
||||||
# Some templates may not support this option
|
# Some templates may not support this option
|
||||||
|
|||||||
Reference in New Issue
Block a user