You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/actions/sharing-automations/creating-actions/creating-a-javascript-action.md
+85-54Lines changed: 85 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ Before you begin, you'll need to download Node.js and create a public {% data va
39
39
1. Download and install Node.js 20.x, which includes npm.
40
40
41
41
https://nodejs.org/en/download/
42
+
42
43
1. Create a new public repository on {% data variables.product.github %} and call it "hello-world-javascript-action". For more information, see [AUTOTITLE](/repositories/creating-and-managing-repositories/creating-a-new-repository).
43
44
44
45
1. Clone your repository to your computer. For more information, see [AUTOTITLE](/repositories/creating-and-managing-repositories/cloning-a-repository).
@@ -60,19 +61,22 @@ Before you begin, you'll need to download Node.js and create a public {% data va
60
61
Create a new file named `action.yml` in the `hello-world-javascript-action` directory with the following example code. For more information, see [AUTOTITLE](/actions/creating-actions/metadata-syntax-for-github-actions).
61
62
62
63
```yaml copy
63
-
name: 'Hello World'
64
-
description: 'Greet someone and record the time'
64
+
name: Hello World
65
+
description: Greet someone and record the time
66
+
65
67
inputs:
66
-
who-to-greet: # id of input
67
-
description: 'Who to greet'
68
+
who-to-greet: # id of input
69
+
description: Who to greet
68
70
required: true
69
-
default: 'World'
71
+
default: World
72
+
70
73
outputs:
71
74
time: # id of output
72
-
description: 'The time we greeted you'
75
+
description: The time we greeted you
76
+
73
77
runs:
74
-
using: 'node20'
75
-
main: 'index.js'
78
+
using: node20
79
+
main: dist/index.js
76
80
```
77
81
78
82
This file defines the `who-to-greet` input and `time` output. It also tells the action runner how to start running this JavaScript action.
@@ -90,35 +94,37 @@ The toolkit offers more than the `core` and `github` packages. For more informat
90
94
At your terminal, install the actions toolkit `core` and `github` packages.
91
95
92
96
```shell copy
93
-
npm install @actions/core
94
-
npm install @actions/github
97
+
npm install @actions/core @actions/github
95
98
```
96
99
97
-
Now you should see a `node_modules` directory with the modules you just installed and a `package-lock.json` file with the installed module dependencies and the versions of each installed module.
100
+
You should now see a `node_modules` directory and a `package-lock.json` file which track any installed dependencies and their versions. You should not commit the `node_modules` directory to your repository.
98
101
99
102
## Writing the action code
100
103
101
104
This action uses the toolkit to get the `who-to-greet` input variable required in the action's metadata file and prints "Hello [who-to-greet]" in a debug message in the log. Next, the script gets the current time and sets it as an output variable that actions running later in a job can use.
102
105
103
106
GitHub Actions provide context information about the webhook event, Git refs, workflow, action, and the person who triggered the workflow. To access the context information, you can use the `github` package. The action you'll write will print the webhook event payload to the log.
104
107
105
-
Add a new file called `index.js`, with the following code.
108
+
Add a new file called `src/index.js`, with the following code.
106
109
107
110
{% raw %}
108
111
109
112
```javascript copy
110
-
const core = require('@actions/core');
111
-
const github = require('@actions/github');
113
+
import * as core from "@actions/core";
114
+
import * as github from "@actions/github";
112
115
113
116
try {
114
117
// `who-to-greet` input defined in action metadata file
{% data variables.product.github %} downloads each action run in a workflow during runtime and executes it as a complete package of code before you can use workflow commands like `run` to interact with the runner machine. This means you must include any package dependencies required to run the JavaScript code. You'll need to check in the toolkit `core` and `github` packages to your action's repository.
178
+
{% data variables.product.github %} downloads each action run in a workflow during runtime and executes it as a complete package of code before you can use workflow commands like `run` to interact with the runner machine. This means you must include any package dependencies required to run the JavaScript code. For example, this action uses `@actions/core` and `@actions/github` packages.
173
179
174
-
From your terminal, commit your `action.yml`, `index.js`, `node_modules`, `package.json`, `package-lock.json`, and `README.md` files. If you added a `.gitignore` file that lists `node_modules`, you'll need to remove that line to commit the `node_modules` directory.
180
+
Checking in your `node_modules` directory can cause problems. As an alternative, you can use tools such as [`rollup.js`](https://github.com/rollup/rollup) or [`@vercel/ncc`](https://github.com/vercel/ncc) to combine your code and dependencies into one file for distribution.
175
181
176
-
It's best practice to also add a version tag for releases of your action. For more information on versioning your action, see [AUTOTITLE](/actions/creating-actions/about-custom-actions#using-release-management-for-actions).
182
+
1. Install `rollup` and its plugins by running this command in your terminal.
Checking in your `node_modules` directory can cause problems. As an alternative, you can use a tool called [`@vercel/ncc`](https://github.com/vercel/ncc) to compile your code and modules into one file used for distribution.
You'll see a new `dist/index.js` file with your code and the compiled modules. You will also see an accompanying `dist/licenses.txt` file containing all the licenses of the `node_modules` you are using.
196
-
197
-
1. Change the `main` keyword in your `action.yml` file to use the new `dist/index.js` file.
203
+
exportdefaultconfig;
204
+
```
198
205
199
-
`main: 'dist/index.js'`
206
+
1. Compile your `dist/index.js` file.
200
207
201
-
1. If you already checked in your `node_modules` directory, remove it.
208
+
`rollup --config rollup.config.js`
202
209
203
-
`rm -rf node_modules/*`
210
+
You'll see a new `dist/index.js` file with your code and any dependencies.
204
211
205
-
1. From your terminal, commit the updates to your `action.yml`, `dist/index.js`, and `node_modules` files.
run: echo "The time was ${{ steps.hello.outputs.time }}"
@@ -253,25 +280,29 @@ When this workflow is triggered, the runner will download the `hello-world-javas
253
280
254
281
Copy the workflow code into a `.github/workflows/main.yml` file in your action's repository. You can also replace the `who-to-greet` input with your name.
255
282
256
-
**.github/workflows/main.yml**
257
-
258
283
```yaml copy
259
-
on: [push]
284
+
on:
285
+
push:
286
+
branches:
287
+
- main
260
288
261
289
jobs:
262
290
hello_world_job:
263
-
runs-on: ubuntu-latest
264
291
name: A job to say hello
292
+
runs-on: ubuntu-latest
293
+
265
294
steps:
266
295
# To use this repository's private action,
267
296
# you must check out the repository
268
297
- name: Checkout
269
298
uses: {% data reusables.actions.action-checkout %}
299
+
270
300
- name: Hello world action step
271
301
uses: ./ # Uses an action in the root directory
272
302
id: hello
273
303
with:
274
-
who-to-greet: 'Mona the Octocat'
304
+
who-to-greet: Mona the Octocat
305
+
275
306
# Use the output from the `hello` step
276
307
- name: Get the output time
277
308
run: echo "The time was {% raw %}${{ steps.hello.outputs.time }}{% endraw %}"
Copy file name to clipboardExpand all lines: content/copilot/using-github-copilot/copilot-chat/asking-github-copilot-questions-in-github.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ redirect_from:
20
20
21
21
{% data variables.copilot.copilot_chat_dotcom %} is a chat interface that lets you ask and receive answers to coding-related questions on the {% data variables.product.github %} website.
22
22
23
-
{% data variables.copilot.copilot_chat_short %} can help you with a variety of coding-related tasks, like offering you code suggestions, providing natural language descriptions of a piece of code's functionality and purpose, generating unit tests for your code, and proposing fixes for bugs in your code. For more information, see [AUTOTITLE](/copilot/github-copilot-chat/copilot-chat-in-github/about-github-copilot-chat-in-githubcom).
23
+
{% data variables.copilot.copilot_chat_short %} can help you with a variety of coding-related tasks, like offering you code suggestions, providing natural language descriptions of a piece of code's functionality and purpose, generating unit tests for your code, and proposing fixes for bugs in your code.
24
24
25
25
On {% data variables.product.github %}, you can use {% data variables.copilot.copilot_chat_short %} to ask different questions in different contexts. For example, you can ask about a specific repository, a specific issue, or a specific pull request. You can also ask general questions about software development, or about a specific programming language.
Copy file name to clipboardExpand all lines: data/release-notes/enterprise-server/3-17/0.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -207,7 +207,7 @@ sections:
207
207
- |
208
208
When publishing npm packages in a workflow after restoring from a backup to GitHub Enterprise Server 3.13.5.gm4 or 3.14.2.gm3, you may encounter a `401 Unauthorized` error from the GitHub Packages service. This can happen if the restore is from an N-1 or N-2 version and the workflow targets the npm endpoint on the backup instance. To avoid this issue, ensure the access token is valid and includes the correct scopes for publishing to GitHub Packages.
209
209
- |
210
-
Uploading a new license with unbundled GitHub Advanced Security may not fully unbundle all the Security Configurations on the instance in certain cases. Any active Security Configurations will continue to function, but when attempting to apply the configurations to new repositories you may see errors like "Advanced Security is not purchased" or `Validation failed: Secret scanning non provider patterns Non-provider patterns must be disabled when secret scanning is disabled`. Contact GitHub Support for assistance clearing this state in version 3.17.0. This issue will be resolved in version 3.17.1.
210
+
Uploading a new license with unbundled GitHub Advanced Security may not fully unbundle all the Security Configurations on the instance in certain cases. Any active Security Configurations will continue to function, but when attempting to apply the configurations to new repositories you may see errors like "Advanced Security is not purchased" or `Validation failed: Secret scanning non provider patterns Non-provider patterns must be disabled when secret scanning is disabled`. Contact GitHub Support for assistance clearing this state in version 3.17.0. This issue will be resolved in version 3.17.2.
0 commit comments