mirror of
https://github.com/actions/container-action.git
synced 2025-06-15 01:37:42 +00:00
Replace named arg
This commit is contained in:
parent
137e75c6a6
commit
f67457a744
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -48,8 +48,8 @@ jobs:
|
|||||||
INPUT_WHO_TO_GREET: Mona Lisa Octocat
|
INPUT_WHO_TO_GREET: Mona Lisa Octocat
|
||||||
run: |
|
run: |
|
||||||
docker run \
|
docker run \
|
||||||
--env INPUT_WHO_TO_GREET="Mona Lisa Octocat" \
|
--rm ${{ env.TEST_TAG }} \
|
||||||
--rm ${{ env.TEST_TAG }}
|
${{ env.INPUT_WHO_TO_GREET }}
|
||||||
|
|
||||||
test-action:
|
test-action:
|
||||||
name: GitHub Actions Test
|
name: GitHub Actions Test
|
||||||
|
26
README.md
26
README.md
@ -51,21 +51,10 @@ need to perform some initial setup steps before you can develop your action.
|
|||||||
|
|
||||||
1. :white_check_mark: Test the container
|
1. :white_check_mark: Test the container
|
||||||
|
|
||||||
You can pass individual environment variables using the `--env` or `-e` flag.
|
You can pass input arguments in the `docker run` call.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ docker run --env INPUT_WHO_TO_GREET="Mona Lisa Octocat" actions/container-action
|
$ docker run actions/container-action "Mona Lisa Octocat"
|
||||||
|
|
||||||
::notice file=entrypoint.sh,line=7::Hello, Mona Lisa Octocat!
|
|
||||||
```
|
|
||||||
|
|
||||||
Or you can pass a file with environment variables using `--env-file`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ cat ./.env.test
|
|
||||||
INPUT_WHO_TO_GREET="Mona Lisa Octocat"
|
|
||||||
|
|
||||||
$ docker run --env-file ./.env.test actions/container-action
|
|
||||||
|
|
||||||
::notice file=entrypoint.sh,line=7::Hello, Mona Lisa Octocat!
|
::notice file=entrypoint.sh,line=7::Hello, Mona Lisa Octocat!
|
||||||
```
|
```
|
||||||
@ -87,13 +76,12 @@ can choose any base Docker image and language you like, you can change this to
|
|||||||
suite your needs. There are a few main things to remember when writing code for
|
suite your needs. There are a few main things to remember when writing code for
|
||||||
container actions:
|
container actions:
|
||||||
|
|
||||||
- Inputs are accessed using environment variables with the format
|
- Inputs are accessed using argument identifiers. For example, the first input
|
||||||
`INPUT_<INPUT_NAME>`. For example, this action has an input called
|
to this action, `who-to-greet`, can be accessed in the entrypoint script using
|
||||||
`who-to-greet`, which can be accessed in the entrypoint script using
|
`$1`.
|
||||||
`INPUT_WHO_TO_GREET`.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
GREETING="Hello, $INPUT_WHO_TO_GREET!"
|
GREETING="Hello, $1!"
|
||||||
```
|
```
|
||||||
|
|
||||||
- GitHub Actions supports a number of different workflow commands such as
|
- GitHub Actions supports a number of different workflow commands such as
|
||||||
@ -140,7 +128,7 @@ So, what are you waiting for? Go ahead and start customizing your action!
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t actions/container-action .
|
docker build -t actions/container-action .
|
||||||
docker run --env INPUT_WHO_TO_GREET="Mona Lisa Octocat" actions/container-action
|
docker run actions/container-action "Mona Lisa Octocat"
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Commit your changes
|
1. Commit your changes
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/sh -l
|
||||||
|
|
||||||
# Use INPUT_<INPUT_NAME> to get the value of an input
|
# Use INPUT_<INPUT_NAME> to get the value of an input
|
||||||
GREETING="Hello, $INPUT_WHO_TO_GREET!"
|
GREETING="Hello, $1!"
|
||||||
|
|
||||||
# Use workflow commands to do things like set debug messages
|
# Use workflow commands to do things like set debug messages
|
||||||
echo "::notice file=entrypoint.sh,line=7::$GREETING"
|
echo "::notice file=entrypoint.sh,line=7::$GREETING"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user