Compare commits

..

10 Commits
0.2.0 ... 0.3.0

Author SHA1 Message Date
Jonathan Clem
9f3a1f1343 Add GitHub as author 2019-11-13 15:04:08 -08:00
Jonathan Clem
72fd1e6109 Make some minor changes to README 2019-11-13 15:03:01 -08:00
Jonathan Clem
470a4bfd94 Merge pull request #11 from actions/ethomson/update_description
Update description
2019-11-13 15:02:38 -08:00
Jonathan Clem
71fcc9050d Pass "require" to function context 2019-11-13 14:54:26 -08:00
Edward Thomson
4f0c94ef13 Update description 2019-11-08 16:22:35 +00:00
Jonathan Clem
d910cb8d03 Merge pull request #4 from JJ/master
Adds example that uses the github object
2019-11-07 11:16:48 -05:00
Juan Julián Merelo Guervós
4404120432 Update README.md as requested
Co-Authored-By: Jonathan Clem <jclem@github.com>
2019-09-17 21:40:17 +02:00
Juan Julián Merelo Guervós
1d11b7fefb Update README.md as requested
Co-Authored-By: Jonathan Clem <jclem@github.com>
2019-09-17 21:39:56 +02:00
Jonathan Clem
47683009b7 Update README.md 2019-09-17 15:07:13 -04:00
JJ Merelo
4418551f1d Adds example with use of github object 2019-09-06 09:15:54 +02:00
3 changed files with 32 additions and 6 deletions

View File

@@ -27,13 +27,13 @@ documentation.
```yaml
on:
issue: {type: opened}
issues: {types: opened}
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@0.2.0
- uses: actions/github-script@0.3.0
with:
github-token: ${{github.token}}
script: |
@@ -44,7 +44,7 @@ jobs:
```yaml
on:
issue: {type: opened}
issues: {types: opened}
jobs:
apply-label:
@@ -92,3 +92,28 @@ jobs:
await github.issues.createComment({...context.issue, body: 'Welcome, new contributor!'})
```
### Download data from a URL
You can use the `github` object to access the Octokit API. For
instance, `github.request`
```yaml
on:
pull_request
jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@0.2.0
with:
github-token: ${{github.token}}
script: |
const diff_url = context.payload.pull_request.diff_url
const result = await github.request(diff_url)
console.log(result)
```
This will print the full diff object in the screen; `result.data` will
contain the actual diff text.

View File

@@ -1,5 +1,6 @@
name: GitHub Script
description: An action for running simple scripts with a GitHub client
author: GitHub
description: Run simple scripts using the GitHub client
branding:
color: blue
icon: code

View File

@@ -16,8 +16,8 @@ async function main() {
if (previews != null) opts.previews = previews.split(',')
const client = new GitHub(token, opts)
const script = core.getInput('script', {required: true})
const fn = new AsyncFunction('github', 'context', script)
const result = await fn(client, context)
const fn = new AsyncFunction('require', 'github', 'context', script)
const result = await fn(require, client, context)
core.setOutput('result', JSON.stringify(result))
}