Skip to content

Commit 0a51941

Browse files
committed
docs: Document the composite actions
1 parent b2e9990 commit 0a51941

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

.github/actions/readme.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Devito Actions
2+
3+
The Devito actions can either be used from the Github interface:
4+
```yaml
5+
uses: devitocodes/devito/.github/actions/docker-build@main
6+
```
7+
8+
Or internally from within the repository:
9+
```yaml
10+
uses: ./.github/actions/docker-run
11+
```
12+
13+
## `docker-build`
14+
15+
Inputs:
16+
17+
- `file`: Dockerfile containing build instructions (default: `Dockerfile`)
18+
- `tag`: Tag to add to the built image
19+
- `base`: Base docker image to build on top of
20+
- `args`: Arguments to pass to `docker build`
21+
22+
Outputs:
23+
24+
- `unique`: Unique identifier for the CI run (ie: `${{ steps.build.outputs.unique }}`)
25+
26+
Example:
27+
28+
```yaml
29+
jobs:
30+
test:
31+
steps:
32+
- id: build
33+
name: Build docker image for Devito
34+
uses: ./.github/actions/docker-build
35+
with:
36+
file: docker/Dockerfile.devito
37+
tag: tag-related-to-test-config
38+
base: base-image-to-build-from
39+
args: "--more-docker-build-args"
40+
```
41+
42+
## `docker-run`
43+
44+
Inputs:
45+
46+
- `uid`: Unique identifier output from docker-build action
47+
- `tag`: Tag of the built image to use
48+
- `name`: Name substring for docker to use when running the command (optional)
49+
- `args`: Arguments to pass to `docker run`, `--init -t --rm` are always added
50+
- `env`: Environment variables to set inside the docker container, one environment variable per line
51+
-command: Command to execute inside of the docker container
52+
53+
### Notes
54+
55+
- The UID must be unique, easily obtained from build action
56+
- The tag must match built image, easily obtained from build action
57+
- If you provide a custom name `foo` the container name will be `ci-foo-UUUUUUUUUU` where UUUUUUUUUU is the UID
58+
- The default args `--init -t --rm` are _always_ added
59+
- Environment variables must be passed a single environment variable per line, best achieved with the (`|`) syntax in yaml
60+
- Only a single command is executed, not a list of commands. Using `;` or `&&` will result in subsequent commands being executed outside of the docker environment
61+
62+
Example:
63+
64+
```yaml
65+
jobs:
66+
test:
67+
steps:
68+
- name: Run a command in a previously built Docker container
69+
uses: ./.github/actions/docker-run
70+
with:
71+
uid: ${{ steps.build.outputs.unique }}
72+
tag: tag-related-to-test-config
73+
name: completely-optional-name
74+
args: "--more-docker-run-args"
75+
env: |
76+
FOO=value1
77+
BAR=value2
78+
command: |
79+
mpiexec -n 4 \
80+
python \
81+
my_complicated_script.py --arg1 -v
82+
```
83+
84+
## `docker-clean`
85+
86+
Inputs:
87+
88+
- `uid`: Unique identifier output from docker-build action
89+
- `tag`: Tag of the built image to use
90+
91+
### Notes
92+
93+
- UID must be unique, easily obtained from build action
94+
- Tag must match built image, easily obtained from build action
95+
- Use `if: always()` to always clean up the image, even if the workflow fails
96+
97+
Example:
98+
99+
```yaml
100+
jobs:
101+
test:
102+
steps:
103+
- name: Cleanup Docker image
104+
if: always()
105+
uses: ./.github/actions/docker-clean
106+
with:
107+
uid: ${{ steps.build.outputs.unique }}
108+
tag: tag-related-to-test-config
109+
```

0 commit comments

Comments
 (0)