Skip to content

Commit ad03418

Browse files
committed
Make both _container.yml and _push_container.yml build and test container
1 parent 0788359 commit ad03418

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

.github/workflows/_container.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,3 @@ jobs:
3636

3737
- name: Test cli works in cached runtime image
3838
run: docker run --rm tag_for_testing --version
39-
40-
- name: Upload container as artifact
41-
uses: actions/upload-artifact@v4
42-
with:
43-
name: container
44-
path: ${{ runner.temp }}/myimage.tar

.github/workflows/_push_container.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,41 @@ on:
22
workflow_call:
33

44
jobs:
5-
push:
5+
build:
66
runs-on: ubuntu-latest
77

88
steps:
9-
- name: Download container artifact
10-
uses: actions/download-artifact@v4
9+
- name: Checkout
10+
uses: actions/checkout@v4
1111
with:
12-
name: container
13-
path: ${{ runner.temp }}
14-
15-
- name: Load image
16-
run: |
17-
docker load --input ${{ runner.temp}}/myimage.tar
18-
12+
# Need this to get version number from last tag
13+
fetch-depth: 0
14+
15+
- name: Set up Docker Buildx
16+
id: buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Log in to GitHub Docker Registry
20+
if: github.event_name != 'pull_request'
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Build and export to Docker local cache
28+
uses: docker/build-push-action@v6
29+
env:
30+
DOCKER_BUILD_RECORD_UPLOAD: false
31+
with:
32+
context: .
33+
# Need load and tags so we can test it below
34+
load: true
35+
tags: tag_for_testing
36+
37+
- name: Test cli works in cached runtime image
38+
run: docker run --rm tag_for_testing --version
39+
1940
- name: Create tags for publishing image
2041
id: meta
2142
uses: docker/metadata-action@v5
@@ -33,6 +54,7 @@ jobs:
3354
# This does not build the image again, it will find the image in the
3455
# Docker cache and publish it
3556
with:
57+
context: .
3658
push: true
3759
tags: ${{ steps.meta.outputs.tags }}
3860
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)