Skip to content

Commit

Permalink
ci: add publish squashfs layers
Browse files Browse the repository at this point in the history
Signed-off-by: Petu Eusebiu <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Nov 20, 2023
1 parent 92a6802 commit 9ce955a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 22 deletions.
42 changes: 37 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
jobs:
ci:
runs-on: ubuntu-latest
services:
registry:
image: ghcr.io/project-zot/zot-linux-amd64:latest
ports:
- 5000:5000
# services:
# registry:
# image: ghcr.io/project-zot/zot-linux-amd64:latest
# ports:
# - 5000:5000
name: Test stacker-build-push-action
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -98,3 +98,35 @@ jobs:
url: docker://localhost:5000/five/app
layer-type: 'tar squashfs'
skip-tls: true

- name: Run stacker-build with push, tags, build-args and layer-type(squashfs)
uses: ./
with:
file: 'test/stacker.yaml'
build-args: |
SUB1=VAR1
SUB2=VAR2
SUB3=VAR3
tags: v1 latest
url: docker://localhost:5000/six/app
layer-type: 'squashfs'
skip-tls: true

- name: Check images were published
run: |
docker pull localhost:5000/one/app/test:v1
docker pull localhost:5000/one/app/test
docker pull localhost:5000/two/app/test:v1
docker pull localhost:5000/two/app/test
docker pull localhost:5000/three/app/test:v1
docker pull localhost:5000/three/app/test
docker pull localhost:5000/four/app/app:v1
docker pull localhost:5000/four/app/app
docker pull localhost:5000/five/app/layer3_1:v2
docker pull localhost:5000/five/app/layer3_1:v2
# check squashfs
curl http://localhost:5000/v2/six/app/test/manifests/v1-squashfs
curl http://localhost:5000/v2/six/app/test/manifests/latest-squashfs
curl http://localhost:5000/v2/five/app/layer3_2/manifests/v2-squashfs
curl http://localhost:5000/v2/five/app/layer3_1/manifests/v2-squashfs
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inputs:
file-pattern:
description: 'regex pattern to use when searching for stackerfile paths, used with dir arg'
required: false
default: '\\/stacker.yaml$'
default: 'stacker.yaml'
layer-type:
description: 'Set the output layer type (supported values: tar, squashfs) separated by whitespace'
required: false
Expand All @@ -41,7 +41,7 @@ inputs:
description: 'Tags used when pushing to remote OCI registry, separated by whitespace'
required: false
url:
description: 'Remote registry URL, eg: docker://ghcr.io/myRepo'
description: 'Remote registry URL, eg: docker://ghcr.io/myrepo'
required: false
username:
description: 'Username for the remote registry'
Expand Down
3 changes: 1 addition & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12573,7 +12573,7 @@ class StackerCLI {
finalExecOptions.env = execEnv;
try {
const exitCode = yield exec.exec(this.executable, args, finalExecOptions);
if (execOptions.ignoreReturnCode !== true && exitCode !== 0) {
if (exitCode !== 0) {
let error = `${external_path_.basename(this.executable)} exited with code ${exitCode}`;
if (stderr) {
error += `\n${stderr}`;
Expand Down Expand Up @@ -12732,7 +12732,6 @@ function run() {
const substitutes = getInputList("build-args");
var subfile = core.getInput("build-args-file");
const layerTypes = getSpaceSeparatedInput("layer-type");
core.info(`dockerfile val: ${dockerfile}`);
if (dockerfile) {
let [cmdRes, convertRes] = yield cli.convertDockerfile(dockerfile);
if (convertRes && (yield cmdRes).exitCode == 0) {
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export async function run(): Promise<void> {
// get layer-type from input
const layerTypes = utils.getSpaceSeparatedInput("layer-type");

core.info(`dockerfile val: ${dockerfile}`);
if (dockerfile) {
let [cmdRes, convertRes] = await cli.convertDockerfile(dockerfile);

Expand Down
2 changes: 1 addition & 1 deletion src/stacker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class StackerCLI {
try {
const exitCode = await exec.exec(this.executable, args, finalExecOptions);

if (execOptions.ignoreReturnCode !== true && exitCode !== 0) {
if (exitCode !== 0) {
// Throwing the stderr as part of the Error makes the stderr
// show up in the action outline, which saves some clicking when debugging.
let error = `${path.basename(this.executable)} exited with code ${exitCode}`;
Expand Down
6 changes: 3 additions & 3 deletions test/builds/first/stacker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ layer1_1:
type: docker
url: docker://centos:latest
import:
- import1
- importfile1
run: |
cp /stacker/imports/import1 /root/import1
cp /stacker/imports/importfile1 /root/importfile1
layer1_2:
from:
type: docker
url: docker://centos:latest
run:
touch /root/import0
touch /root/importfile0
8 changes: 4 additions & 4 deletions test/builds/second/stacker.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
config:
prerequisites:
- ../sub1/stacker.yaml
- ../first/stacker.yaml
layer2:
from:
type: built
tag: layer1_1
import:
- import2
- importfile2
run: |
cp /stacker/imports/import2 /root/import2
cp /root/import1 /root/import1_copied
cp /stacker/imports/importfile2 /root/importfile2
cp /root/importfile1 /root/importfile1_copied
8 changes: 4 additions & 4 deletions test/builds/third/stacker.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
config:
prerequisites:
- ../sub1/stacker.yaml
- ../sub2/stacker.yaml
- ../first/stacker.yaml
- ../second/stacker.yaml
layer3_1:
from:
type: built
tag: layer2
run: |
cp /root/import2 /root/import2_copied
cp /root/importfile2 /root/importfile2_copied
layer3_2:
from:
type: built
tag: layer1_2
run: |
cp /root/import0 /root/import0_copied
cp /root/importfile0 /root/importfile0_copied

0 comments on commit 9ce955a

Please sign in to comment.