diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 282b637..ba27c47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,11 +15,22 @@ jobs: uses: actions/checkout@v3 - name: Run + id: run_test uses: ./ with: - base-image: docker://rust:slim-buster + base-image: docker://ghcr.io/clementtsang/cargo-deb-arm derived-image: docker://rust:slim-buster + - name: Check + run: | + echo Result: ${{ steps.run_test.outputs.differs }} + if [ ${{ steps.run_test.outputs.differs }} == 'true' ]; then + exit 0 + else + echo "differs should always be true!" + exit 1 + fi + test-always-false: runs-on: ubuntu-latest steps: @@ -27,7 +38,18 @@ jobs: uses: actions/checkout@v3 - name: Run + id: run_test uses: ./ with: - base-image: docker://ghcr.io/clementtsang/cargo-deb-arm + base-image: docker://rust:slim-buster derived-image: docker://rust:slim-buster + + - name: Check + run: | + echo Result: ${{ steps.run_test.outputs.differs }} + if [ ${{ steps.run_test.outputs.differs }} == 'false' ]; then + exit 0 + else + echo "differs should always be false!" + exit 1 + fi diff --git a/README.md b/README.md index 695d7a7..db29017 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,26 @@ A required argument, this represents the "base" image you want to check against. As this is based on `skopeo`, it expects a string representing a container, and following a certain format (e.g. `docker://rust:slim-buster`). For more information, see [the `skopeo` README](https://github.com/containers/skopeo#skopeo-). -### Outputs +#### `derived-image` A required argument, this represents the "derived" image you want to check. As this is based on `skopeo`, it expects a string representing a container, and following a certain format (e.g. `docker://rust:slim-buster`). For more information, see [the `skopeo` README](https://github.com/containers/skopeo#skopeo-). + +### Outputs + +#### `differs` + +The action returns either `true` or `false`, indicating if the derived image differs from the base image (e.g. if derived does not contain the base, it returns `true`). + +## Example + +```yaml +- name: Run +id: run +uses: ClementTsang/docker-check-base-image-diff@v0.0.1-alpha +with: + base-image: docker://rust:slim-buster + derived-image: docker://ghcr.io/clementtsang/cargo-deb-arm +``` diff --git a/action.yml b/action.yml index daddafe..e610289 100644 --- a/action.yml +++ b/action.yml @@ -11,13 +11,14 @@ inputs: required: true outputs: differs: - description: "True or false" - value: ${{ steps.check.outputs.result }} + description: "Returns either true or false" + value: ${{ steps.check.outputs.differs }} + runs: using: "composite" steps: - id: check shell: bash run: | - result=$(${{ github.action_path }}/check.sh ${{ inputs.base-image }} ${{ inputs.derived-image }}) - echo "::set-output name=result::${result}" + RESULT=$(${{ github.action_path }}/check.sh ${{ inputs.base-image }} ${{ inputs.derived-image }}) + echo "::set-output name=differs::$RESULT" diff --git a/check.sh b/check.sh index a54d6cb..1da51e4 100755 --- a/check.sh +++ b/check.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + BASE_LAYERS="$(skopeo inspect $1 | jq '.Layers')" DERIVED_LAYERS="$(skopeo inspect $2 | jq '.Layers')"