Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/instructions/github-script.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
description: GitHub Action Script Source Code
applyTo: "pkg/workflow/js/*.cjs"
---

This JavaScript file will be run using the GitHub Action `actions/github-script@v7` which provides the `@actions/core`, `@actions/github` packages for logging errors and setting action status.

- do not add import or require for `@actions/core`
- reference:
- https://github.com/actions/toolkit/blob/main/packages/core/README.md
- https://github.com/actions/toolkit/blob/main/packages/github/README.md

## Best practices

- use `core.info`, `core.warning`, `core.error` for logging, not `console.log` or `console.error`
- use `core.debug` for verbose debug logging, which can be enabled in action settings
- use `core.setOutput` to set action outputs
- use `core.exportVariable` to set environment variables for subsequent steps
- use `core.getInput` to get action inputs, with `required: true` for mandatory inputs
- use `core.setFailed` to mark the action as failed with an error message

## Step summary

Use `core.summary.*` function to write output the step summary file.

- use `core.summary.addRaw()` to add raw Markdown content (GitHub Flavored Markdown supported)
- make sure to call `core.summary.write()` to flush pending writes
- summary function calls can be chained, e.g. `core.summary.addRaw(...).addRaw(...).write()`

## Common errors

- avoid `any` type as much as possible, use specific types or `unknown` instead
- catch handler: check if error is an instance of Error before accessing message property

```js
catch (error) {
core.setFailed(error instanceof Error ? error : String(error));
}
```

- `core.setFailed` also calls `core.error`, so do not call both

## Typechecking

Run `make js` to run the typescript compiler.

Run `make lint-cjs` to lint the files.

Run `make fmt-cjs` after editing to format the file.
205 changes: 127 additions & 78 deletions .github/workflows/ci-doctor.lock.yml

Large diffs are not rendered by default.

135 changes: 76 additions & 59 deletions .github/workflows/test-safe-output-add-issue-comment.lock.yml

Large diffs are not rendered by default.

129 changes: 73 additions & 56 deletions .github/workflows/test-safe-output-add-issue-label.lock.yml

Large diffs are not rendered by default.

162 changes: 85 additions & 77 deletions .github/workflows/test-safe-output-create-code-scanning-alert.lock.yml

Large diffs are not rendered by default.

143 changes: 78 additions & 65 deletions .github/workflows/test-safe-output-create-discussion.lock.yml

Large diffs are not rendered by default.

154 changes: 84 additions & 70 deletions .github/workflows/test-safe-output-create-issue.lock.yml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

167 changes: 91 additions & 76 deletions .github/workflows/test-safe-output-create-pull-request.lock.yml

Large diffs are not rendered by default.

70 changes: 46 additions & 24 deletions .github/workflows/test-safe-output-missing-tool.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading