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/creating-actions/creating-a-docker-container-action.md
+17-18Lines changed: 17 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Before you begin, you'll need to create a GitHub repository.
39
39
40
40
1. From your terminal, change directories into your new repository.
41
41
42
-
```shell
42
+
```shell{:copy}
43
43
cd hello-world-docker-action
44
44
```
45
45
@@ -48,7 +48,7 @@ Before you begin, you'll need to create a GitHub repository.
48
48
In your new `hello-world-docker-action` directory, create a new `Dockerfile` file. For more information, see "[Dockerfile support for {% data variables.product.prodname_actions %}](/actions/creating-actions/dockerfile-support-for-github-actions)."
49
49
50
50
**Dockerfile**
51
-
```dockerfile
51
+
```dockerfile{:copy}
52
52
# Container image that runs your code
53
53
FROM alpine:3.10
54
54
@@ -65,7 +65,7 @@ Create a new `action.yml` file in the `hello-world-docker-action` directory you
65
65
66
66
{% raw %}
67
67
**action.yml**
68
-
```yaml
68
+
```yaml{:copy}
69
69
# action.yml
70
70
name: 'Hello World'
71
71
description: 'Greet someone and record the time'
@@ -93,29 +93,28 @@ This metadata defines one `who-to-greet` input and one `time` output parameter.
93
93
94
94
You can choose any base Docker image and, therefore, any language for your action. The following shell script example uses the `who-to-greet` input variable to print "Hello [who-to-greet]" in the log file.
95
95
96
-
Next, the script gets the current time and sets it as an output variable that actions running later in a job can use. In order for {% data variables.product.prodname_dotcom %} to recognize output variables, you must use a workflow command in a specific syntax: `echo "::set-output name=<output name>::<value>"`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)."
96
+
Next, the script gets the current time and sets it as an output variable that actions running later in a job can use. In order for {% data variables.product.prodname_dotcom %} to recognize output variables, you must use a workflow command in a specific syntax: `echo "::set-output name=<output name>::<value>"`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)."
97
97
98
98
1. Create a new `entrypoint.sh` file in the `hello-world-docker-action` directory.
99
99
100
-
1. Make your `entrypoint.sh` file executable:
101
-
102
-
```shell
103
-
chmod +x entrypoint.sh
104
-
```
105
-
106
100
1. Add the following code to your `entrypoint.sh` file.
107
101
108
102
**entrypoint.sh**
109
-
```shell
103
+
```shell{:copy}
110
104
#!/bin/sh -l
111
105
112
106
echo "Hello $1"
113
107
time=$(date)
114
108
echo "::set-output name=time::$time"
115
109
```
116
-
117
110
If `entrypoint.sh` executes without any errors, the action's status is set to `success`. You can also explicitly set exit codes in your action's code to provide an action's status. For more information, see "[Setting exit codes for actions](/actions/creating-actions/setting-exit-codes-for-actions)."
118
111
112
+
1. Make your `entrypoint.sh` file executable by running the following command on your system.
113
+
114
+
```shell{:copy}
115
+
$ chmod +x entrypoint.sh
116
+
```
117
+
119
118
### Creating a README
120
119
121
120
To let people know how to use your action, you can create a README file. A README is most helpful when you plan to share your action publicly, but is also a great way to remind you or your team how to use the action.
@@ -130,7 +129,7 @@ In your `hello-world-docker-action` directory, create a `README.md` file that sp
130
129
- An example of how to use your action in a workflow.
131
130
132
131
**README.md**
133
-
```markdown
132
+
```markdown{:copy}
134
133
# Hello world docker action
135
134
136
135
This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
@@ -160,7 +159,7 @@ From your terminal, commit your `action.yml`, `entrypoint.sh`, `Dockerfile`, and
160
159
161
160
It's best practice to also add a version tag for releases of your action. For more information on versioning your action, see "[About actions](/actions/automating-your-workflow-with-github-actions/about-actions#using-release-management-for-actions)."
@@ -175,11 +174,11 @@ Now you're ready to test your action out in a workflow. When an action is in a p
175
174
176
175
#### Example using a public action
177
176
178
-
The following workflow code uses the completed hello world action in the public [`actions/hello-world-docker-action`](https://github.com/actions/hello-world-docker-action) repository. Copy the following workflow example code into a `.github/workflows/main.yml` file, but replace the `actions/hello-world-docker-action` with your repository and action name. You can also replace the `who-to-greet` input with your name.
177
+
The following workflow code uses the completed _hello world_ action in the public [`actions/hello-world-docker-action`](https://github.com/actions/hello-world-docker-action) repository. Copy the following workflow example code into a `.github/workflows/main.yml` file, but replace the `actions/hello-world-docker-action` with your repository and action name. You can also replace the `who-to-greet` input with your name. {% if currentVersion == "free-pro-team@latest" %}Public actions can be used even if they're not published to {% data variables.product.prodname_marketplace %}. For more information, see "[Publishing an action](/actions/creating-actions/publishing-actions-in-github-marketplace#publishing-an-action)." {% endif %}
179
178
180
179
{% raw %}
181
180
**.github/workflows/main.yml**
182
-
```yaml
181
+
```yaml{:copy}
183
182
on: [push]
184
183
185
184
jobs:
@@ -200,11 +199,11 @@ jobs:
200
199
201
200
#### Example using a private action
202
201
203
-
Copy the following example 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.
202
+
Copy the following example 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. {% if currentVersion == "free-pro-team@latest" %}This private action can't be published to {% data variables.product.prodname_marketplace %}, and can only be used in this repository.{% endif %}
Copy file name to clipboardExpand all lines: content/actions/guides/building-and-testing-java-with-ant.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Ant template when you c
38
38
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
39
39
40
40
{% raw %}
41
-
```yaml
41
+
```yaml{:copy}
42
42
name: Java CI
43
43
44
44
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the default target specified in your _build.xml_ f
79
79
If you use different commands to build your project, or you want to run a different target, you can specify those. For example, you may want to run the `jar` target that's configured in your _build-ci.xml_ file.
80
80
81
81
{% raw %}
82
-
```yaml
82
+
```yaml{:copy}
83
83
steps:
84
84
- uses: actions/checkout@v2
85
85
- uses: actions/setup-java@v1
@@ -97,7 +97,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
97
97
Ant will usually create output files like JARs, EARs, or WARs in the `build/jar` directory. You can upload the contents of that directory using the `upload-artifact` action.
Copy file name to clipboardExpand all lines: content/actions/guides/building-and-testing-java-with-gradle.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Gradle template when yo
38
38
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
39
39
40
40
{% raw %}
41
-
```yaml
41
+
```yaml{:copy}
42
42
name: Java CI
43
43
44
44
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the `build` task by default. In the default Gradle
79
79
If you use different commands to build your project, or you want to use a different task, you can specify those. For example, you may want to run the `package` task that's configured in your _ci.gradle_ file.
80
80
81
81
{% raw %}
82
-
```yaml
82
+
```yaml{:copy}
83
83
steps:
84
84
- uses: actions/checkout@v2
85
85
- uses: actions/setup-java@v1
@@ -95,7 +95,7 @@ steps:
95
95
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Gradle package cache will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote package repositories. For more information, see "<ahref="/actions/guides/caching-dependencies-to-speed-up-workflows"class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
96
96
97
97
{% raw %}
98
-
```yaml
98
+
```yaml{:copy}
99
99
steps:
100
100
- uses: actions/checkout@v2
101
101
- name: Set up JDK 1.8
@@ -122,7 +122,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
122
122
Gradle will usually create output files like JARs, EARs, or WARs in the `build/libs` directory. You can upload the contents of that directory using the `upload-artifact` action.
Copy file name to clipboardExpand all lines: content/actions/guides/building-and-testing-java-with-maven.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Maven template when you
38
38
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
39
39
40
40
{% raw %}
41
-
```yaml
41
+
```yaml{:copy}
42
42
name: Java CI
43
43
44
44
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the `package` target by default. In the default Ma
79
79
If you use different commands to build your project, or you want to use a different target, you can specify those. For example, you may want to run the `verify` target that's configured in a _pom-ci.xml_ file.
80
80
81
81
{% raw %}
82
-
```yaml
82
+
```yaml{:copy}
83
83
steps:
84
84
- uses: actions/checkout@v2
85
85
- uses: actions/setup-java@v1
@@ -95,7 +95,7 @@ steps:
95
95
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Maven repository will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote Maven repositories. For more information, see "<ahref="/actions/guides/caching-dependencies-to-speed-up-workflows"class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
96
96
97
97
{% raw %}
98
-
```yaml
98
+
```yaml{:copy}
99
99
steps:
100
100
- uses: actions/checkout@v2
101
101
- name: Set up JDK 1.8
@@ -122,7 +122,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
122
122
Maven will usually create output files like JARs, EARs, or WARs in the `target` directory. To upload those as artifacts, you can copy them into a new directory that contains artifacts to upload. For example, you can create a directory called `staging`. Then you can upload the contents of that directory using the `upload-artifact` action.
Copy file name to clipboardExpand all lines: content/actions/guides/building-and-testing-nodejs.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ The template includes a matrix strategy that builds and tests your code with fou
77
77
Each job can access the value defined in the matrix `node-version` array using the `matrix` context. The `setup-node` action uses the context as the `node-version` input. The `setup-node` action configures each job with a different Node.js version before building and testing code. For more information about matrix strategies and contexts, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)" and "[Context and expression syntax for {% data variables.product.prodname_actions %}](/actions/reference/context-and-expression-syntax-for-github-actions)."
78
78
79
79
{% raw %}
80
-
```yaml
80
+
```yaml{:copy}
81
81
strategy:
82
82
matrix:
83
83
node-version: [10.x, 12.x, 14.x, 15.x]
@@ -93,7 +93,7 @@ steps:
93
93
94
94
Alternatively, you can build and test with exact Node.js versions.
95
95
96
-
```yaml
96
+
```yaml{:copy}
97
97
strategy:
98
98
matrix:
99
99
node-version: [8.16.2, 10.17.0]
@@ -102,7 +102,7 @@ strategy:
102
102
Or, you can build and test using a single version of Node.js too.
103
103
104
104
{% raw %}
105
-
```yaml
105
+
```yaml{:copy}
106
106
name: Node.js CI
107
107
108
108
on: [push]
@@ -136,7 +136,7 @@ When using {% data variables.product.prodname_dotcom %}-hosted runners, you can
136
136
137
137
This example installs the dependencies defined in the *package.json* file. For more information, see [`npm install`](https://docs.npmjs.com/cli/install).
138
138
139
-
```yaml
139
+
```yaml{:copy}
140
140
steps:
141
141
- uses: actions/checkout@v2
142
142
- name: Use Node.js
@@ -150,7 +150,7 @@ steps:
150
150
Using `npm ci` installs the versions in the *package-lock.json* or *npm-shrinkwrap.json* file and prevents updates to the lock file. Using `npm ci` is generally faster than running `npm install`. For more information, see [`npm ci`](https://docs.npmjs.com/cli/ci.html) and "[Introducing `npm ci` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)."
151
151
152
152
{% raw %}
153
-
```yaml
153
+
```yaml{:copy}
154
154
steps:
155
155
- uses: actions/checkout@v2
156
156
- name: Use Node.js
@@ -166,7 +166,7 @@ steps:
166
166
167
167
This example installs the dependencies defined in the *package.json* file. For more information, see [`yarn install`](https://yarnpkg.com/en/docs/cli/install).
168
168
169
-
```yaml
169
+
```yaml{:copy}
170
170
steps:
171
171
- uses: actions/checkout@v2
172
172
- name: Use Node.js
@@ -179,7 +179,7 @@ steps:
179
179
180
180
Alternatively, you can pass `--frozen-lockfile` to install the versions in the *yarn.lock* file and prevent updates to the *yarn.lock* file.
181
181
182
-
```yaml
182
+
```yaml{:copy}
183
183
steps:
184
184
- uses: actions/checkout@v2
185
185
- name: Use Node.js
@@ -201,7 +201,7 @@ In the example below, the secret `NPM_TOKEN` stores the npm authentication token
201
201
Before installing dependencies, use the `setup-node` action to create the *.npmrc* file. The action has two input parameters. The `node-version` parameter sets the Node.js version, and the `registry-url` parameter sets the default registry. If your package registry uses scopes, you must use the `scope` parameter. For more information, see [`npm-scope`](https://docs.npmjs.com/misc/scope).
202
202
203
203
{% raw %}
204
-
```yaml
204
+
```yaml{:copy}
205
205
steps:
206
206
- uses: actions/checkout@v2
207
207
- name: Use Node.js
@@ -231,7 +231,7 @@ always-auth=true
231
231
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache dependencies using a unique key, and restore the dependencies when you run future workflows using the `cache` action. For more information, see "<ahref="/actions/guides/caching-dependencies-to-speed-up-workflows"class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
232
232
233
233
{% raw %}
234
-
```yaml
234
+
```yaml{:copy}
235
235
steps:
236
236
- uses: actions/checkout@v2
237
237
- name: Use Node.js
@@ -256,7 +256,7 @@ steps:
256
256
257
257
You can use the same commands that you use locally to build and test your code. For example, if you run `npm run build` to run build steps defined in your *package.json* file and `npm test` to run your test suite, you would add those commands in your workflow file.
0 commit comments