Skip to content

Commit eb8b7fe

Browse files
committed
Correcting check and adding an explicit explaination of what happens with caching
1 parent de723ad commit eb8b7fe

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.github/workflows/test-twostep-container-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
117117
- name: Check the output
118118
run: |
119-
if [ "${{ steps.twostep-2.outputs.summary }}" == "re-built" ]; then
119+
if [ "${{ steps.twostep-2.outputs.summary }}" == "rebuilt" ]; then
120120
echo "Using a re-built version (OK)"
121121
else
122122
echo "This was supposed to use the cache version"

twostep-container-build/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ flowchart LR
99
Containerfile2-->|Generates|Image2
1010
```
1111

12+
The bulk of the action is dealing with whether the first image is available or not. If available, the action will check if the cache key matches the hash of the container file. If it does, the action will skip the first step and use the cached image. If the cache key does not match, the action will build the image and push it to the registry (if `push-image-1` is set to `true`):
13+
14+
```mermaid
15+
flowchart TB
16+
subgraph "Caching"
17+
start((Start)) --> tag_exists
18+
tag_exists{Tag exists}-->|Yes|pull_image
19+
pull_image[Pull image<br>& inspect<br>labels]-->check_label
20+
check_label{Label<br>matches<br>hash}-->|Yes|done((Done))
21+
check_label-->|No|build_image["Build image<br>& push (optional)"]
22+
tag_exists-->|No|build_image
23+
build_image-->done
24+
end
25+
```
26+
1227
Caching is done by storing the cache-key as a label in the image (`TWO_STEP_BUILD_CACHE_KEY`); and the build and push process is done using the [docker/build-push-action@v6](https://github.com/docker/build-push-action/tree/v6) action. Users have to explicitly provide the cache key for the first step. For example, if you are dealing with an R package, you can cache the dependencies by passing the key `${{ hashFiles('DESCRIPTION') }}` to the `first-step-cache-key` input. That way, the first step will only be executed if the dependencies change.
1328

1429
## Inputs and Outputs

0 commit comments

Comments
 (0)