Compare commits

..
2 Commits
Author SHA1 Message Date
Francesco Renzi 4aed96e0ba Merge pull request #376 from actions/rentziass/actions-core
Bump @actions/core to 1.10.0 for v2
2023-04-28 14:13:11 +01:00
Francesco Renzi e7d3d7ecb7 Bump @actions/core to 1.10.0 2023-04-28 12:26:08 +01:00
61 changed files with 11576 additions and 19760 deletions

No files matched your search

-38
View File
@@ -1,38 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
-20
View File
@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
-52
View File
@@ -1,52 +0,0 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process
# from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
+8 -9
View File
@@ -1,20 +1,19 @@
name: CI
on: on:
push: push: {branches: main}
branches: [main] pull_request: {branches: main}
pull_request:
branches: [main]
jobs: jobs:
ci: ci:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v1
with: {node-version: 13.x}
- uses: actions/cache@v1
with: with:
node-version: 12 path: ~/.npm
cache: npm key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
restore-keys: ${{runner.os}}-npm-
- run: npm ci - run: npm ci
- run: npm run style:check - run: npm run style:check
- run: npm test - run: npm test
+3 -45
View File
@@ -1,18 +1,12 @@
name: Integration
on: on:
push: push: {branches: main}
branches: [main]
pull_request:
branches: [main]
jobs: jobs:
test-return: integration:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2
- id: output-set - id: output-set
uses: ./ uses: actions/github-script@main
with: with:
script: return core.getInput('input-value') script: return core.getInput('input-value')
result-encoding: string result-encoding: string
@@ -21,39 +15,3 @@ jobs:
if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then
exit 1 exit 1
fi fi
test-relative-require:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: output-set
uses: ./
with:
script: return require('./package.json').name
result-encoding: string
input-value: output
- run: |
if [[ "${{steps.output-set.outputs.result}}" != "github-script" ]]; then
exit 1
fi
test-npm-require:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
restore-keys: ${{runner.os}}-npm-
- run: npm ci
- id: output-set
uses: ./
with:
script: return require('@actions/core/package.json').name
result-encoding: string
input-value: output
- run: |
if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then
exit 1
fi
+11 -8
View File
@@ -1,12 +1,10 @@
name: Licensed name: Licensed
on: on:
push: push: {branches: main}
branches: pull_request: {branches: main}
- main repository_dispatch:
pull_request: workflow_dispatch:
branches:
- main
jobs: jobs:
test: test:
@@ -14,11 +12,16 @@ jobs:
name: Check licenses name: Check licenses
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
restore-keys: ${{runner.os}}-npm-
- run: npm ci - run: npm ci
- name: Install licensed - name: Install licensed
run: | run: |-
cd $RUNNER_TEMP cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.9.2/licensed-2.9.2-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed sudo mv licensed /usr/local/bin/licensed
- run: licensed status - run: licensed status
+15 -21
View File
@@ -1,8 +1,6 @@
name: Pull Request Test
on: on:
pull_request: pull_request:
branches: [main] branches: main
types: [opened, synchronize] types: [opened, synchronize]
jobs: jobs:
@@ -14,7 +12,7 @@ jobs:
with: with:
script: | script: |
// Get the existing comments. // Get the existing comments.
const {data: comments} = await github.rest.issues.listComments({ const {data: comments} = await github.issues.listComments({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: context.payload.number, issue_number: context.payload.number,
@@ -24,22 +22,18 @@ 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') { if (botComment) {
console.log('Not attempting to write comment on PR from fork'); await github.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else { } else {
if (botComment) { await github.issues.createComment({
await github.rest.issues.updateComment({ owner: context.repo.owner,
owner: context.repo.owner, repo: context.repo.repo,
repo: context.repo.repo, issue_number: context.payload.number,
comment_id: botComment.id, body: commentBody
body: commentBody })
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: commentBody
})
}
} }
-31
View File
@@ -1,31 +0,0 @@
name: Stale Issues & PRs
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
mark_stale:
name: Mark issues and PRs as stale
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
exempt-issue-labels: Not Stale
exempt-pr-labels: Not Stale
stale-issue-message: >
This issue is stale because it has been open for 60 days with no
activity. Remove the "Stale" label or comment on the issue, or it
will be closed in 7 days.
stale-pr-message: >
This pull request is stale because it has been open for 60 days
with no activity. Remove the "Stale" label or comment on the pull
request, or it will be closed in 7 days.
close-issue-message: >
This issue has been marked as stale and closed due to no activity
on it.
close-pr-message: >
This pull request has been marked as stale and closed due to no
activity on it.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
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.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
* @actions/actions-experience
+27 -193
View File
@@ -1,8 +1,4 @@
# actions/github-script # github-script ![.github/workflows/integration.yml](https://github.com/actions/github-script/workflows/.github/workflows/integration.yml/badge.svg?event=push) ![.github/workflows/ci.yml](https://github.com/actions/github-script/workflows/.github/workflows/ci.yml/badge.svg?event=push)
[![.github/workflows/integration.yml](https://github.com/actions/github-script/workflows/Integration/badge.svg?event=push&branch=main)](https://github.com/actions/github-script/actions?query=workflow%3AIntegration+branch%3Amain+event%3Apush)
[![.github/workflows/ci.yml](https://github.com/actions/github-script/workflows/CI/badge.svg?event=push&branch=main)](https://github.com/actions/github-script/actions?query=workflow%3ACI+branch%3Amain+event%3Apush)
[![.github/workflows/licensed.yml](https://github.com/actions/github-script/workflows/Licensed/badge.svg?event=push&branch=main)](https://github.com/actions/github-script/actions?query=workflow%3ALicensed+branch%3Amain+event%3Apush)
This action makes it easy to quickly write a script in your workflow that This action makes it easy to quickly write a script in your workflow that
uses the GitHub API and the workflow run context. uses the GitHub API and the workflow run context.
@@ -12,19 +8,11 @@ input should be the body of an asynchronous function call. The following
arguments will be provided: arguments will be provided:
- `github` A pre-authenticated - `github` A pre-authenticated
[octokit/rest.js](https://octokit.github.io/rest.js) client with pagination plugins [octokit/rest.js](https://github.com/octokit/rest.js) client
- `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
- `exec` A reference to the [@actions/exec](https://github.com/actions/toolkit/tree/main/packages/exec) package
- `require` A proxy wrapper around the normal Node.js `require` to enable
requiring relative paths (relative to the current working directory) and
requiring npm packages installed in the current working directory. If for
some reason you need the non-wrapped `require`, there is an escape hatch
available: `__original_require__` is the original value of `require` without
our wrapping applied.
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
defined, so you don't have to (see examples below). defined, so you don't have to (see examples below).
@@ -32,13 +20,8 @@ defined, so you don't have to (see examples below).
See [octokit/rest.js](https://octokit.github.io/rest.js/) for the API client See [octokit/rest.js](https://octokit.github.io/rest.js/) for the API client
documentation. documentation.
## Breaking changes in V5 **Note** This action is still a bit of an experiment—the API may change in
future versions. 🙂
Version 5 of this action includes the version 5 of `@actions/github` and `@octokit/plugin-rest-endpoint-methods`. As part of this update, the Octokit context available via `github` no longer has REST methods directly. These methods are available via `github.rest.*` - https://github.com/octokit/plugin-rest-endpoint-methods.js/releases/tag/v5.0.0
For example, `github.issues.createComment` in V4 becomes `github.rest.issues.createComment` in V5
`github.request`, `github.paginate`, and `github.graphql` are unchanged.
## Development ## Development
@@ -50,7 +33,7 @@ The return value of the script will be in the step's outputs under the
"result" key. "result" key.
```yaml ```yaml
- uses: actions/github-script@v5 - uses: actions/github-script@v2
id: set-result id: set-result
with: with:
script: return "Hello!" script: return "Hello!"
@@ -69,9 +52,10 @@ output of a github-script step. For some workflows, string encoding is preferred
`result-encoding` input: `result-encoding` input:
```yaml ```yaml
- uses: actions/github-script@v5 - uses: actions/github-script@v2
id: my-script id: my-script
with: with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string result-encoding: string
script: return "I will be string (not JSON) encoded!" script: return "I will be string (not JSON) encoded!"
``` ```
@@ -83,15 +67,6 @@ 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@v5
with:
script: console.log(context)
```
### Comment on an issue ### Comment on an issue
```yaml ```yaml
@@ -103,10 +78,11 @@ jobs:
comment: comment:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v5 - uses: actions/github-script@v2
with: with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
github.rest.issues.createComment({ github.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -125,10 +101,11 @@ jobs:
apply-label: apply-label:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v5 - uses: actions/github-script@v2
with: with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
github.rest.issues.addLabels({ github.issues.addLabels({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -145,13 +122,14 @@ jobs:
welcome: welcome:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v5 - uses: actions/github-script@v2
with: with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
// Get a list of all issues created by the PR opener // Get a list of all issues created by the PR opener
// See: https://octokit.github.io/rest.js/#pagination // See: https://octokit.github.io/rest.js/#pagination
const creator = context.payload.sender.login const creator = context.payload.sender.login
const opts = github.rest.issues.listForRepo.endpoint.merge({ const opts = github.issues.listForRepo.endpoint.merge({
...context.issue, ...context.issue,
creator, creator,
state: 'all' state: 'all'
@@ -168,7 +146,7 @@ jobs:
} }
} }
await github.rest.issues.createComment({ await github.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -188,8 +166,9 @@ jobs:
diff: diff:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/github-script@v5 - uses: actions/github-script@v2
with: with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: | script: |
const diff_url = context.payload.pull_request.diff_url const diff_url = context.payload.pull_request.diff_url
const result = await github.request(diff_url) const result = await github.request(diff_url)
@@ -203,36 +182,6 @@ using the API.)_
This will print the full diff object in the screen; `result.data` will This will print the full diff object in the screen; `result.data` will
contain the actual diff text. contain the actual diff text.
### Run custom GraphQL queries
You can use the `github.graphql` object to run custom GraphQL queries against the GitHub API.
```yaml
jobs:
list-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v5
with:
script: |
const query = `query($owner:String!, $name:String!, $label:String!) {
repository(owner:$owner, name:$name){
issues(first:100, labels: [$label]) {
nodes {
id
}
}
}
}`;
const variables = {
owner: context.repo.owner,
name: context.repo.repo,
label: 'wontfix'
}
const result = await github.graphql(query, variables)
console.log(result)
```
### Run a separate file ### Run a separate file
If you don't want to inline your entire script that you want to run, you can If you don't want to inline your entire script that you want to run, you can
@@ -246,21 +195,26 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/github-script@v5 - uses: actions/github-script@v2
with: with:
script: | script: |
const script = require('./path/to/script.js') const script = require(`${process.env.GITHUB_WORKSPACE}/path/to/script.js`)
console.log(script({github, context})) console.log(script({github, context}))
``` ```
*Note that the script path given to `require()` must be an **absolute path** in this case, hence using [`GITHUB_WORKSPACE`](https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables).*
And then export a function from your module: And then export a function from your module:
```javascript ```javascript
module.exports = ({github, context}) => { module.exports = (github, context) => {
return context.payload.client_payload.value return context.payload.client_payload.value
} }
``` ```
You can also use async functions in this manner, as long as you `await` it in
the inline script.
Note that because you can't `require` things like the GitHub context or Note that because you can't `require` things like the GitHub context or
Actions Toolkit libraries, you'll want to pass them as arguments to your Actions Toolkit libraries, you'll want to pass them as arguments to your
external function. external function.
@@ -268,123 +222,3 @@ 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.
### Run a separate file with an async function
You can also use async functions in this manner, as long as you `await` it in
the inline script.
In your workflow:
```yaml
on: push
jobs:
echo-input:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/github-script@v5
env:
SHA: '${{env.parentSHA}}'
with:
script: |
const script = require('./path/to/script.js')
await script({github, context, core})
```
And then export an async function from your module:
```javascript
module.exports = async ({github, context, core}) => {
const {SHA} = process.env
const commit = await github.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `${SHA}`
})
core.exportVariable('author', commit.data.commit.author.email)
}
```
### Use npm packages
Like importing your own files above, you can also use installed modules.
Note that this is achieved with a wrapper on top `require`, so if you're
trying to require a module inside your own file, you might need to import
it externally or pass the `require` wrapper to your file:
```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@v5
with:
script: |
const execa = require('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@v5
env:
FIRST_NAME: Mona
LAST_NAME: Octocat
with:
script: |
const { FIRST_NAME, LAST_NAME } = process.env
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
```
### Using a separate GitHub token
The `GITHUB_TOKEN` used by default is scoped to the current repository, see [Authentication in a workflow](https://docs.github.com/actions/reference/authentication-in-a-workflow).
If you need access to a different repository or an API that the `GITHUB_TOKEN` doesn't have permissions to, you can provide your own [PAT](https://help.github.com/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) as a secret using the `github-token` input.
[Learn more about creating and using encrypted secrets](https://docs.github.com/actions/reference/encrypted-secrets)
```yaml
on:
issues:
types: [opened]
jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v5
with:
github-token: ${{ secrets.MY_PAT }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Triage']
})
```
+9031 -8697
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -22,7 +22,7 @@ well.
Releases are done manually, for now: Releases are done manually, for now:
1. Ensure that the build is up to date with `npm run build`. It's also good to ensure you have the correct dependencies installed by running `npm install` before you build. 1. Ensure that the build is up to date with `npm run build`.
1. Bump the [package.json](/package.json#L3) and [package-lock.json](/package-lock.json#L3) version numbers and commit them. I like to do this with `npm version {major,minor,patch} --no-git-tag-version`. This will bump the version numbers but let you manually commit and tag, yourself. 1. Bump the [package.json](/package.json#L3) and [package-lock.json](/package-lock.json#L3) version numbers and commit them.
1. Update documentation (including updated version numbers). 1. Update documentation (including updated version numbers).
1. Tag main with the new version number and create a GitHub release. Make sure you also force-create and force-push tags for minor and patch updates. For example, when creating v5.1.0 (a minor bump), you want to create (or update) `v5`, `v5.1`, and `v5.1.0`. 1. Tag main with the new version number and create a GitHub release.
+2461 -10580
View File
File diff suppressed because it is too large. Load diff
+16 -18
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": "5.0.0", "version": "2.1.0",
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
@@ -35,27 +35,25 @@
} }
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.5.0", "@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0", "@actions/github": "^3.0.0",
"@actions/github": "^5.0.0", "@actions/io": "^1.0.2",
"@actions/glob": "^0.2.0", "@octokit/core": "^2.5.3",
"@actions/io": "^1.1.1", "@octokit/plugin-paginate-rest": "^2.2.1",
"@octokit/core": "^3.5.1", "@octokit/plugin-rest-endpoint-methods": "^3.17.0"
"@octokit/plugin-paginate-rest": "^2.16.4",
"@octokit/plugin-rest-endpoint-methods": "^5.11.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.24", "@types/jest": "^25.1.4",
"@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^3.10.1", "@typescript-eslint/parser": "^2.33.0",
"@vercel/ncc": "^0.23.0", "@zeit/ncc": "^0.22.0",
"eslint": "^7.32.0", "eslint": "^7.0.0",
"eslint-config-prettier": "^6.15.0", "eslint-config-prettier": "^6.11.0",
"husky": "^4.2.5", "husky": "^4.2.5",
"jest": "^26.6.3", "jest": "^25.1.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^2.0.5", "prettier": "^2.0.5",
"ts-jest": "^26.5.6", "ts-jest": "^25.2.1",
"typescript": "^4.3.5" "typescript": "^3.8.3"
} }
} }
-5
View File
@@ -1,8 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as exec from '@actions/exec'
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
@@ -11,11 +9,8 @@ type AsyncFunctionArguments = {
context: Context context: Context
core: typeof core core: typeof core
github: InstanceType<typeof GitHub> github: InstanceType<typeof GitHub>
exec: typeof exec
glob: typeof glob
io: typeof io io: typeof io
require: NodeRequire require: NodeRequire
__original_require__: NodeRequire
} }
export function callAsyncFunction<T>( export function callAsyncFunction<T>(
+1 -13
View File
@@ -1,10 +1,7 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import * as exec from '@actions/exec'
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'
import {wrapRequire} from './wrap-require'
process.on('unhandledRejection', handleError) process.on('unhandledRejection', handleError)
main().catch(handleError) main().catch(handleError)
@@ -31,16 +28,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: wrapRequire,
__original_require__: __non_webpack_require__,
github,
context,
core,
exec,
glob,
io
},
script script
) )
-25
View File
@@ -1,25 +0,0 @@
import * as path from 'path'
export const wrapRequire = new Proxy(__non_webpack_require__, {
apply: (target, thisArg, [moduleID]) => {
if (moduleID.startsWith('.')) {
moduleID = path.resolve(moduleID)
return target.apply(thisArg, [moduleID])
}
const modulePath = target.resolve.apply(thisArg, [
moduleID,
{
// Webpack does not have an escape hatch for getting the actual
// module, other than `eval`.
paths: [process.cwd()]
}
])
return target.apply(thisArg, [modulePath])
},
get: (target, prop, receiver) => {
Reflect.get(target, prop, receiver)
}
})
-1
View File
@@ -1 +0,0 @@
declare const __non_webpack_require__: NodeRequire