Compare commits

..
28 Commits
Author SHA1 Message Date
Francesco Renzi ffc2c79a5b Merge pull request #348 from actions/rentziass/core-v3
Upgrade @actions/core to 1.10.0 for v3
2023-03-10 17:18:05 +00:00
Francesco Renzi 1ef439ceeb Bump version to 3.2.0 2023-03-10 16:57:58 +00:00
Francesco Renzi b86401ed73 Upgrade @actions/core to 1.10.0 2023-03-10 16:53:12 +00:00
Josh Gross f05a81df23 Update version to 3.1.1 2021-03-30 14:00:42 -04:00
Josh Gross 74ae80c200 Use y18n 4.0.1 2021-03-30 13:56:06 -04:00
Josh Gross 7488ca4f39 Merge pull request #127 from MatisseHack/glob
Add @actions/glob as a script parameter
2021-03-30 13:53:12 -04:00
Matisse Hack 8920b9a6ed Add the @actions/glob package 2021-03-29 16:06:39 -07:00
Josh Gross 8685086334 Merge pull request #126 from nihalgonsalves/ng/input
Document how to use npm packages and env input
2021-03-29 17:35:07 -04:00
Nihal Gonsalves 01dfe2e0c1 Update README.md 2021-03-30 02:48:37 +05:30
Nihal Gonsalves 934655b9e0 Document how to use env: as input 2021-03-30 02:23:20 +05:30
Nihal Gonsalves a56d4504de Document how to use installed npm packages 2021-03-30 02:20:10 +05:30
Josh Gross 3d069b2f0c Merge pull request #121 from robyoung/fix-previous-broken-pr
Fix typo from #117
2021-03-03 15:31:04 -05:00
Rob Young 77c8747753 Fix typo from #117
I accidentally removed two lines I did not intend to. This would only
break for PRs opened on the repo directly.
2021-03-02 11:41:59 +00:00
Josh Gross e86864dfd7 Merge pull request #117 from robyoung/fix-pull-request-test-for-forks
Fix PR test workflow for forks
2021-02-26 15:55:52 -05:00
Rob Young 58e7e1dbfa Fix PR test workflow for forks
When the workflow is triggered from a fork the permissions for the
`GITHUB_TOKEN` are read-only. This chane skips the write operations if
we're running from a fork.

See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-events-for-forked-repositories
2021-02-23 09:36:43 +00:00
Josh Gross b251c3e139 Merge pull request #111 from actions/dependabot/npm_and_yarn/node-notifier-8.0.1
Bump node-notifier from 8.0.0 to 8.0.1
2021-02-02 11:53:29 -05:00
dependabot[bot] 5b5c43cb7b Bump node-notifier from 8.0.0 to 8.0.1
Bumps [node-notifier](https://github.com/mikaelbr/node-notifier) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/mikaelbr/node-notifier/releases)
- [Changelog](https://github.com/mikaelbr/node-notifier/blob/v8.0.1/CHANGELOG.md)
- [Commits](https://github.com/mikaelbr/node-notifier/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-02 16:51:20 +00:00
Josh Gross 74776b4afc Merge pull request #110 from buger/patch-1
Fix typo in Readme example
2021-02-02 11:46:17 -05:00
Leonid Bugaev 01904b97ff Fix typo in Readme example
$label was not defined as input argument. 

Also updated job name to reflect what it actually does.
2021-02-02 17:12:35 +03:00
Josh Gross 315fb4f388 Merge pull request #109 from 36degrees/patch-1
Use @v3 in 'View context attributes' example
2021-01-04 13:20:42 -05:00
Oliver Byford 5c9e354ff0 Use @v3 in 'View context attributes' example
This makes the version of github-script used in the 'View context attributes' example consistent with the version used by all of the other examples in the README.
2020-12-21 15:16:05 +00:00
Josh Gross 2f21207c8d Add name to PR test workflow 2020-12-17 12:09:06 -05:00
Josh Gross 1318dc37ba Merge pull request #108 from Bullenj01/documentation-print-option-for-objects
Update README.md
2020-12-17 12:07:59 -05:00
Jason Bullen f4f25ebaab Move to examples section 2020-12-17 11:45:30 -05:00
Jason Bullen b91d578158 Update README.md
Add example of using console.log to display attributes of object context
2020-12-17 08:33:49 -05:00
Josh Gross a52e7f4cf4 Merge pull request #106 from actions/joshmgross/add-codeowners
Add CODEOWNERS
2020-12-10 13:27:30 -05:00
Josh Gross b714c526d7 Add CODEOWNERS 2020-12-09 15:58:34 -05:00
Jonathan Clem 96374ece58 Update README.md 2020-11-17 09:20:10 -05:00
13 changed files with 13502 additions and 68 deletions

No files matched your search

+6
View File
@@ -1,3 +1,5 @@
name: Pull Request Test
on: on:
pull_request: pull_request:
branches: main branches: main
@@ -22,6 +24,9 @@ jobs:
const botComment = comments.find(comment => comment.user.id === 41898282) const botComment = comments.find(comment => comment.user.id === 41898282)
const commentBody = "Hello from actions/github-script! (${{ github.sha }})" const commentBody = "Hello from actions/github-script! (${{ github.sha }})"
if (context.payload.pull_request.head.repo.full_name !== 'actions/github-script') {
console.log('Not attempting to write comment on PR from fork');
} else {
if (botComment) { if (botComment) {
await github.issues.updateComment({ await github.issues.updateComment({
owner: context.repo.owner, owner: context.repo.owner,
@@ -37,3 +42,4 @@ jobs:
body: commentBody body: commentBody
}) })
} }
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
* @actions/actions-experience
+63 -5
View File
@@ -16,6 +16,7 @@ arguments will be provided:
- `context` An object containing the [context of the workflow - `context` An object containing the [context of the workflow
run](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts) run](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts)
- `core` A reference to the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package - `core` A reference to the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package
- `glob` A reference to the [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob) package
- `io` A reference to the [@actions/io](https://github.com/actions/toolkit/tree/main/packages/io) package - `io` A reference to the [@actions/io](https://github.com/actions/toolkit/tree/main/packages/io) package
Since the `script` is just a function body, these values will already be Since the `script` is just a function body, these values will already be
@@ -71,6 +72,15 @@ in case you need to use a non-default token.
By default, github-script will use the token provided to your workflow. By default, github-script will use the token provided to your workflow.
### Print the available attributes of context
```yaml
- name: View context attributes
uses: actions/github-script@v3
with:
script: console.log(context)
```
### Comment on an issue ### Comment on an issue
```yaml ```yaml
@@ -191,16 +201,15 @@ contain the actual diff text.
You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API. You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API.
```yaml ```yaml
jobs: jobs:
list-packages: list-issues:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v3 - uses: actions/github-script@v3
with: with:
github-token: ${{secrets.GITHUB_TOKEN}} github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
const query = `query($owner:String!, $name:String!) { const query = `query($owner:String!, $name:String!, $label:String!) {
repository(owner:$owner, name:$name){ repository(owner:$owner, name:$name){
issues(first:100, labels: [$label]) { issues(first:100, labels: [$label]) {
nodes { nodes {
@@ -216,7 +225,6 @@ jobs:
} }
const result = await github.graphql(query, variables) const result = await github.graphql(query, variables)
console.log(result) console.log(result)
``` ```
### Run a separate file ### Run a separate file
@@ -232,7 +240,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/github-script@v2 - uses: actions/github-script@v3
with: with:
script: | script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/path/to/script.js`) const script = require(`${process.env.GITHUB_WORKSPACE}/path/to/script.js`)
@@ -259,3 +267,53 @@ external function.
Additionally, you'll want to use the [checkout Additionally, you'll want to use the [checkout
action](https://github.com/actions/checkout) to make sure your script file is action](https://github.com/actions/checkout) to make sure your script file is
available. available.
### Use npm packages
Like importing your own files above, you can also use installed modules:
```yaml
on: push
jobs:
echo-input:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm ci
# or one-off:
- run: npm install execa
- uses: actions/github-script@v3
with:
script: |
const execa = require(`${process.env.GITHUB_WORKSPACE}/node_modules/execa`)
const { stdout } = await execa('echo', ['hello', 'world'])
console.log(stdout)
```
### Use env as input
You can set env vars to use them in your script:
```yaml
on: push
jobs:
echo-input:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
env:
FIRST_NAME: Mona
LAST_NAME: Octocat
with:
script: |
const { FIRST_NAME, LAST_NAME } = process.env
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
```
+4274 -28
View File
File diff suppressed because it is too large. Load diff
+9151 -32
View File
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "github-script", "name": "github-script",
"description": "A GitHub action for executing a simple script", "description": "A GitHub action for executing a simple script",
"version": "3.1.0", "version": "3.2.0",
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
@@ -35,8 +35,9 @@
} }
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.10.0",
"@actions/github": "^4.0.0", "@actions/github": "^4.0.0",
"@actions/glob": "^0.1.1",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@octokit/core": "^3.2.1", "@octokit/core": "^3.2.1",
"@octokit/plugin-paginate-rest": "^2.6.0", "@octokit/plugin-paginate-rest": "^2.6.0",
+2
View File
@@ -1,6 +1,7 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {Context} from '@actions/github/lib/context' import {Context} from '@actions/github/lib/context'
import {GitHub} from '@actions/github/lib/utils' import {GitHub} from '@actions/github/lib/utils'
import * as glob from '@actions/glob'
import * as io from '@actions/io' import * as io from '@actions/io'
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
@@ -9,6 +10,7 @@ type AsyncFunctionArguments = {
context: Context context: Context
core: typeof core core: typeof core
github: InstanceType<typeof GitHub> github: InstanceType<typeof GitHub>
glob: typeof glob
io: typeof io io: typeof io
require: NodeRequire require: NodeRequire
} }
+2 -1
View File
@@ -1,5 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import {context, getOctokit} from '@actions/github' import {context, getOctokit} from '@actions/github'
import * as glob from '@actions/glob'
import * as io from '@actions/io' import * as io from '@actions/io'
import {callAsyncFunction} from './async-function' import {callAsyncFunction} from './async-function'
@@ -28,7 +29,7 @@ async function main(): Promise<void> {
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors. // Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
const result = await callAsyncFunction( const result = await callAsyncFunction(
{require: require, github, context, core, io}, {require: require, github, context, core, glob, io},
script script
) )