Skip to content

Commit

Permalink
Merge pull request #126 from metanorma/feature/dive-action
Browse files Browse the repository at this point in the history
metanorma/metanorma-docker#177 add own dive action
  • Loading branch information
CAMOBAP authored Sep 27, 2023
2 parents 6a167c4 + 4202141 commit e8ef9bf
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,26 @@ jobs:

- run: |
[ ${{ steps.gh-repo-status.outputs.public }} = "${{ matrix.result }}" ]
shell: bash
shell: bash
test-dive-action:
name: Test dive-action ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # macos-latest - no docker installed , windows-latest - no experimental options enabled by default
steps:
- uses: actions/checkout@v3

- shell: bash
run: |
cat > Dockerfile << EOF
FROM alpine:latest
CMD ["echo", "'Hello World!'"]
EOF
docker build . -t ci-test-image --platform=linux/amd64
- uses: ./dive-action
with:
image: ci-test-image
56 changes: 56 additions & 0 deletions dive-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: dive
description: |
Action for the Dive, a tool for exploring a docker image, layer contents.
https://github.com/wagoodman/dive
inputs:
image:
description: Docker image to analyze
required: true
github-token:
description: Token to be able post comment on PR
default: ''
dive-version:
description: Version of Dive
default: v0.11.0
dive-output-file:
description: Path to file where output will be stored temporarelly
default: ./.dive.output.txt

outputs:
output:
description: Dive report
value: ${{ steps.dive.outputs.report }}

runs:
using: "composite"
steps:
- id: dive
shell: bash
run: |
docker pull wagoodman/dive:${{ inputs.dive-version }}
docker run \
-e CI=true -e DOCKER_API_VERSION=1.37 \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
wagoodman/dive:${{ inputs.dive-version }} \
${{ inputs.image }} > ${{ inputs.dive-output-file }}
echo "Dive report:"
cat ${{ inputs.dive-output-file }}
echo "report<<EOF" >> $GITHUB_OUTPUT
cat ${{ inputs.dive-output-file }} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- if: ${{ inputs.github-token != '' && github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: github.outputs.report
})

0 comments on commit e8ef9bf

Please sign in to comment.