Skip to content

Commit 3d243a3

Browse files
author
Martin Lopes
authored
Merge pull request #2988 from avinal/avinal-improve-docs
Improve docs to be more explanatory
2 parents 01a0e3c + 4acf00b commit 3d243a3

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

content/actions/creating-actions/creating-a-docker-container-action.md

+17-18
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Before you begin, you'll need to create a GitHub repository.
3939

4040
1. From your terminal, change directories into your new repository.
4141

42-
```shell
42+
```shell{:copy}
4343
cd hello-world-docker-action
4444
```
4545

@@ -48,7 +48,7 @@ Before you begin, you'll need to create a GitHub repository.
4848
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)."
4949

5050
**Dockerfile**
51-
```dockerfile
51+
```dockerfile{:copy}
5252
# Container image that runs your code
5353
FROM alpine:3.10
5454
@@ -65,7 +65,7 @@ Create a new `action.yml` file in the `hello-world-docker-action` directory you
6565

6666
{% raw %}
6767
**action.yml**
68-
```yaml
68+
```yaml{:copy}
6969
# action.yml
7070
name: 'Hello World'
7171
description: 'Greet someone and record the time'
@@ -93,29 +93,28 @@ This metadata defines one `who-to-greet` input and one `time` output parameter.
9393

9494
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.
9595

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)."
9797

9898
1. Create a new `entrypoint.sh` file in the `hello-world-docker-action` directory.
9999

100-
1. Make your `entrypoint.sh` file executable:
101-
102-
```shell
103-
chmod +x entrypoint.sh
104-
```
105-
106100
1. Add the following code to your `entrypoint.sh` file.
107101

108102
**entrypoint.sh**
109-
```shell
103+
```shell{:copy}
110104
#!/bin/sh -l
111105
112106
echo "Hello $1"
113107
time=$(date)
114108
echo "::set-output name=time::$time"
115109
```
116-
117110
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)."
118111

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+
119118
### Creating a README
120119

121120
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
130129
- An example of how to use your action in a workflow.
131130

132131
**README.md**
133-
```markdown
132+
```markdown{:copy}
134133
# Hello world docker action
135134
136135
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
160159

161160
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)."
162161

163-
```shell
162+
```shell{:copy}
164163
git add action.yml entrypoint.sh Dockerfile README.md
165164
git commit -m "My first action is ready"
166165
git tag -a -m "My first action release" v1
@@ -175,11 +174,11 @@ Now you're ready to test your action out in a workflow. When an action is in a p
175174

176175
#### Example using a public action
177176

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 %}
179178

180179
{% raw %}
181180
**.github/workflows/main.yml**
182-
```yaml
181+
```yaml{:copy}
183182
on: [push]
184183
185184
jobs:
@@ -200,11 +199,11 @@ jobs:
200199

201200
#### Example using a private action
202201

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 %}
204203

205204
{% raw %}
206205
**.github/workflows/main.yml**
207-
```yaml
206+
```yaml{:copy}
208207
on: [push]
209208
210209
jobs:

0 commit comments

Comments
 (0)