Skip to content

Commit fccfdbd

Browse files
committed
TMP: is this working?
1 parent 76e19a3 commit fccfdbd

File tree

5 files changed

+46
-78
lines changed

5 files changed

+46
-78
lines changed

.github/actions/build/action.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ inputs:
1111
default: "false"
1212

1313
outputs:
14-
tags:
15-
description: "The Docker tags for the image"
16-
value: ${{ steps.meta.outputs.tags }}
1714
version:
1815
description: "The version for the image"
1916
value: ${{ steps.meta.outputs.version }}
@@ -27,9 +24,9 @@ outputs:
2724
runs:
2825
using: "composite"
2926
steps:
30-
# Setup docker to build for multiple architectures
3127
- name: Set up QEMU
3228
uses: docker/setup-qemu-action@v3
29+
3330
- name: Set up Docker Buildx
3431
uses: docker/setup-buildx-action@v1
3532
with:
@@ -65,19 +62,17 @@ runs:
6562
${{ steps.meta.outputs.json }}
6663
EOF
6764
68-
tag=$(cat meta.json | jq -r '.tags[0]')
69-
tag_cache="$tag-cache"
70-
71-
echo "tag=$tag" >> $GITHUB_OUTPUT
72-
echo "tag_cache=$tag_cache" >> $GITHUB_OUTPUT
73-
65+
echo "tag=$(cat meta.json | jq -r '.tags[0]')" >> $GITHUB_OUTPUT
7466
cat $GITHUB_OUTPUT
7567
7668
- name: Tar file
7769
id: tar
7870
shell: bash
71+
# image.tar is the name of the compressed image file
72+
# This should be kept in sync with ./.github/actions/run/action.yml
73+
# That loads the image from this file
7974
run: |
80-
echo "path=/tmp/${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
75+
echo "path=/tmp/image.tar" >> $GITHUB_OUTPUT
8176
8277
- name: Build Image
8378
id: build
@@ -87,8 +82,6 @@ runs:
8782
with:
8883
targets: app
8984
load: true
90-
set: |
91-
*.output=type=docker,dest=${{ steps.tar.outputs.path }}
9285

9386
- name: Get image digest
9487
id: digest
@@ -98,10 +91,17 @@ runs:
9891
echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT
9992
cat $GITHUB_OUTPUT
10093
94+
- name: Save Docker Image to Tar
95+
shell: bash
96+
run: |
97+
docker save -o /tmp/image.tar ${{ steps.tag.outputs.tag }}
98+
10199
- name: Upload artifact
102100
uses: actions/upload-artifact@v4
103101
with:
104-
name: ${{ steps.meta.outputs.version }}
102+
# The artifact name should be kept in sync with
103+
# ./.github/actions/run/action.yml which downloads the artifact
104+
name: docker-image
105105
path: ${{ steps.tar.outputs.path }}
106106
retention-days: 1
107107
compression-level: 9

.github/actions/load/action.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/actions/push/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ runs:
2828
- name: Push Image
2929
shell: bash
3030
run: |
31+
docker image ls
3132
docker image push ${{ inputs.registry }}/${{ inputs.tag }}

.github/actions/run/action.yml

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,42 @@
11
name: 'Docker Run Action'
22
description: 'Run a command in a new container'
33
inputs:
4-
image:
5-
description: "The Docker image to run"
4+
tag:
5+
description: 'The docker image tag to run.'
66
required: true
7-
options:
8-
description: 'Options'
9-
required: false
107
run:
118
description: 'Run command in container'
129
required: true
1310
runs:
1411
using: 'composite'
1512
steps:
16-
- name: Validate inputs
13+
- uses: actions/download-artifact@v4
14+
with:
15+
# The artifact name should be kept in sync with
16+
# ./.github/actions/build/action.yml which uploads the artifact
17+
name: docker-image
18+
path: /tmp/
19+
20+
# image.tar is the name of the compressed image file
21+
# This should be kept in sync with ./.github/actions/build/action.yml
22+
- name: Load image
1723
shell: bash
1824
run: |
19-
if [[ -z "${{ inputs.image }}" ]]; then
20-
echo "Image is required"
21-
exit 1
22-
fi
23-
if [[ -z "${{ inputs.run }}" ]]; then
24-
echo "Run is required"
25-
exit 1
26-
fi
25+
docker load < /tmp/image.tar
26+
docker image ls
27+
2728
- name: Run Docker Container
2829
shell: bash
30+
env:
31+
DOCKER_TAG: ${{ inputs.tag }}
2932
run: |
30-
cat <<EOF > exec.sh
31-
#!/bin/bash
32-
whoami
33-
${{ inputs.run }}
34-
EOF
33+
# Start the specified services
34+
make up
3535
36-
cat <<EOF > root.sh
37-
#!/bin/bash
38-
whoami
39-
su -s /bin/bash -c './exec.sh' root
36+
# Exec the run command in the container
37+
# quoted 'EOF' to prevent variable expansion
38+
cat <<'EOF' | docker compose exec --user root app sh
39+
#!/bin/bash
40+
whoami
41+
${{ inputs.run }}
4042
EOF
41-
42-
# Make both files executable
43-
chmod +x exec.sh
44-
chmod +x root.sh
45-
46-
# Debug info
47-
echo "############"
48-
cat root.sh
49-
echo "############"
50-
echo "############"
51-
cat exec.sh
52-
echo "############"
53-
54-
# Execute inside docker container
55-
cat root.sh | docker run ${{ inputs.options }} \
56-
-i --rm -u 0 \
57-
-v $(pwd):/app \
58-
${{ inputs.image }} bash

.github/workflows/push.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
outputs:
21-
version: ${{ steps.build.outputs.version }}
21+
tag: ${{ steps.build.outputs.tag }}
2222

2323
steps:
2424
- uses: actions/checkout@v4
@@ -46,8 +46,11 @@ jobs:
4646
steps:
4747
- uses: actions/checkout@v4
4848

49-
- uses: ./.github/actions/load
49+
- uses: ./.github/actions/run
5050
with:
51-
version: ${{ needs.build.outputs.version }}
51+
tag: ${{ needs.build.outputs.tag }}
52+
run: |
53+
echo "Hello world"
54+
npm run test
5255
5356

0 commit comments

Comments
 (0)