mirror of
https://github.com/actions/github-script.git
synced 2025-12-09 00:26:20 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f3a1f1343 | ||
|
|
72fd1e6109 | ||
|
|
470a4bfd94 | ||
|
|
71fcc9050d | ||
|
|
4f0c94ef13 | ||
|
|
d910cb8d03 | ||
|
|
4404120432 | ||
|
|
1d11b7fefb | ||
|
|
47683009b7 | ||
|
|
4418551f1d |
31
README.md
31
README.md
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
4
main.js
4
main.js
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user