From c3dcc2056a5cb989464434afe27344b8f6e0ee59 Mon Sep 17 00:00:00 2001 From: Avinal Kumar <185067@nith.ac.in> Date: Tue, 19 Jan 2021 10:06:38 +0530 Subject: [PATCH 1/6] Improve docs to be more explanatory - Added `{:copy}` snippet to all code blocks. - Added a few descriptions about public and private actions - Changed the order of commands and added a description. --- .../creating-a-docker-container-action.md | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index 9d3e36e46fab..7566e1689fd3 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -39,7 +39,7 @@ Before you begin, you'll need to create a GitHub repository. 1. From your terminal, change directories into your new repository. - ```shell + ```shell{:copy} cd hello-world-docker-action ``` @@ -48,7 +48,7 @@ Before you begin, you'll need to create a GitHub repository. 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)." **Dockerfile** -```dockerfile +```dockerfile{:copy} # Container image that runs your code FROM alpine:3.10 @@ -65,7 +65,7 @@ Create a new `action.yml` file in the `hello-world-docker-action` directory you {% raw %} **action.yml** -```yaml +```yaml{:copy} # action.yml name: 'Hello World' description: 'Greet someone and record the time' @@ -93,20 +93,14 @@ This metadata defines one `who-to-greet` input and one `time` output parameter. 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. -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=::"`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)." +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=::"`. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter)." 1. Create a new `entrypoint.sh` file in the `hello-world-docker-action` directory. -1. Make your `entrypoint.sh` file executable: - - ```shell - chmod +x entrypoint.sh - ``` - 1. Add the following code to your `entrypoint.sh` file. **entrypoint.sh** - ```shell + ```shell{:copy} #!/bin/sh -l echo "Hello $1" @@ -114,6 +108,12 @@ Next, the script gets the current time and sets it as an output variable that ac echo "::set-output name=time::$time" ``` +1. Make your `entrypoint.sh` file executable by running following command on your system: + + ```shell{:copy} + chmod +x entrypoint.sh + ``` + 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)." ### Creating a README @@ -130,7 +130,7 @@ In your `hello-world-docker-action` directory, create a `README.md` file that sp - An example of how to use your action in a workflow. **README.md** -```markdown +```markdown{:copy} # Hello world docker action This action prints "Hello World" or "Hello" + the name of a person to greet to the log. @@ -160,7 +160,7 @@ From your terminal, commit your `action.yml`, `entrypoint.sh`, `Dockerfile`, and 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)." -```shell +```shell{:copy} git add action.yml entrypoint.sh Dockerfile README.md git commit -m "My first action is ready" git tag -a -m "My first action release" v1 @@ -175,11 +175,11 @@ Now you're ready to test your action out in a workflow. When an action is in a p #### Example using a public action -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. +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. Public actions can be used with or without publishing to marketplace. Publishing a public action requires you to add a release version tag. {% raw %} **.github/workflows/main.yml** -```yaml +```yaml{:copy} on: [push] jobs: @@ -189,6 +189,8 @@ jobs: steps: - name: Hello world action step id: hello + # For unpublished actions put /@ + # For published actions put /@ uses: actions/hello-world-docker-action@v1 with: who-to-greet: 'Mona the Octocat' @@ -200,11 +202,11 @@ jobs: #### Example using a private action -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. +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. You cannot publish a private action to marketplace and can be used only by you in the same repository. {% raw %} **.github/workflows/main.yml** -```yaml +```yaml{:copy} on: [push] jobs: From d1ef194548b814c332cdbecaaeacc412f0a030f3 Mon Sep 17 00:00:00 2001 From: Avinal Kumar <185067@nith.ac.in> Date: Tue, 19 Jan 2021 12:43:56 +0530 Subject: [PATCH 2/6] Update content/actions/creating-actions/creating-a-docker-container-action.md Co-authored-by: Martin Lopes --- .../creating-actions/creating-a-docker-container-action.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index 7566e1689fd3..dfa15165688d 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -202,7 +202,7 @@ jobs: #### Example using a private action -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. You cannot publish a private action to marketplace and can be used only by you in the same repository. +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. This private action can't be published to {% data variables.product.prodname_marketplace %}, and can only be used in this repository. {% raw %} **.github/workflows/main.yml** From 58c63b1626aee419cf67e6aa576d30994634fdf1 Mon Sep 17 00:00:00 2001 From: Avinal Kumar <185067@nith.ac.in> Date: Tue, 19 Jan 2021 12:44:11 +0530 Subject: [PATCH 3/6] Update content/actions/creating-actions/creating-a-docker-container-action.md Co-authored-by: Martin Lopes --- .../creating-actions/creating-a-docker-container-action.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index dfa15165688d..11d350ebdc65 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -175,7 +175,7 @@ Now you're ready to test your action out in a workflow. When an action is in a p #### Example using a public action -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. Public actions can be used with or without publishing to marketplace. Publishing a public action requires you to add a release version tag. +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. 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)." {% raw %} **.github/workflows/main.yml** From f250954fda025f916d66227b93ad3dd722d450bd Mon Sep 17 00:00:00 2001 From: Martin Lopes Date: Wed, 20 Jan 2021 10:19:43 +1000 Subject: [PATCH 4/6] Added versioning for relative link --- .../creating-actions/creating-a-docker-container-action.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index 11d350ebdc65..daec06e7da0d 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -175,7 +175,7 @@ Now you're ready to test your action out in a workflow. When an action is in a p #### Example using a public action -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. 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)." +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 %} {% raw %} **.github/workflows/main.yml** From a0e3146b17fd24fa0640659a8e327bdf835a839a Mon Sep 17 00:00:00 2001 From: Martin Lopes Date: Wed, 20 Jan 2021 13:31:13 +1000 Subject: [PATCH 5/6] Added updates from peer review --- .../creating-a-docker-container-action.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index daec06e7da0d..22da7d1e15d7 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -107,14 +107,13 @@ Next, the script gets the current time and sets it as an output variable that ac time=$(date) echo "::set-output name=time::$time" ``` + 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)." -1. Make your `entrypoint.sh` file executable by running following command on your system: +1. Make your `entrypoint.sh` file executable by running the following command on your system. ```shell{:copy} - chmod +x entrypoint.sh + $ chmod +x entrypoint.sh ``` - - 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)." ### Creating a README @@ -202,7 +201,7 @@ jobs: #### Example using a private action -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. This private action can't be published to {% data variables.product.prodname_marketplace %}, and can only be used in this repository. +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 %} {% raw %} **.github/workflows/main.yml** From 831e440bea2910b6ab5f31aae4fc6dee056237b3 Mon Sep 17 00:00:00 2001 From: Martin Lopes Date: Wed, 20 Jan 2021 15:43:25 +1000 Subject: [PATCH 6/6] Update content/actions/creating-actions/creating-a-docker-container-action.md Co-authored-by: Lucas Costi --- .../creating-actions/creating-a-docker-container-action.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/content/actions/creating-actions/creating-a-docker-container-action.md b/content/actions/creating-actions/creating-a-docker-container-action.md index 22da7d1e15d7..b906f5358e03 100644 --- a/content/actions/creating-actions/creating-a-docker-container-action.md +++ b/content/actions/creating-actions/creating-a-docker-container-action.md @@ -188,8 +188,6 @@ jobs: steps: - name: Hello world action step id: hello - # For unpublished actions put /@ - # For published actions put /@ uses: actions/hello-world-docker-action@v1 with: who-to-greet: 'Mona the Octocat'