Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 010dd19ea8 | |||
| e80844fa43 | |||
| 3183d7b6ca | |||
| 9e8fd309a2 | |||
| 56d9269e05 | |||
| 051404219a | |||
| 188e304e46 | |||
| 37bf67454e | |||
| 4af366371e | |||
| 489579f553 | |||
| 0e9198f1eb | |||
| cb019550d6 | |||
| 2be3df1d29 | |||
| 5572313b1b | |||
| d27436aedb | |||
| 3e36902dc6 | |||
| 538098e0b6 | |||
| d857084903 |
@@ -1,46 +1,59 @@
|
|||||||
name: Docker Build and Push
|
name: Docker Build and Push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
branches: [master]
|
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '30 3 * * 3'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
uses: actions/checkout@v6
|
- uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
|
||||||
|
with:
|
||||||
- name: Set up Docker Buildx
|
dockerfile: Dockerfile
|
||||||
uses: docker/setup-buildx-action@v4
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
- name: Login to Docker Hub
|
needs: lint
|
||||||
if: github.event_name != 'pull_request'
|
steps:
|
||||||
uses: docker/login-action@v4
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- name: Build image
|
||||||
|
run: docker build -t ci-image:${{ github.sha }} .
|
||||||
|
- name: Save image
|
||||||
|
run: docker save ci-image:${{ github.sha }} -o image.tar
|
||||||
|
- uses: ChristopherHX/gitea-upload-artifact@62ac910c5d3dfa85c7cb2df15afe2e342b2407c2 # main
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
path: image.tar
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # main
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
- name: Load image
|
||||||
|
run: docker load < image.tar
|
||||||
|
- name: Run tests
|
||||||
|
run: bash tests/test.sh ci-image:${{ github.sha }}
|
||||||
|
push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
|
||||||
|
- uses: ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7 # main
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
- name: Load image
|
||||||
|
run: docker load < image.tar
|
||||||
|
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Tag and push
|
||||||
- name: Docker metadata
|
run: |
|
||||||
id: meta
|
docker tag ci-image:${{ github.sha }} jcabillot/sslscan:latest
|
||||||
uses: docker/metadata-action@v6
|
docker push jcabillot/sslscan:latest
|
||||||
with:
|
|
||||||
images: jcabillot/sslscan
|
|
||||||
tags: |
|
|
||||||
#type=ref,event=branch
|
|
||||||
#type=ref,event=pr
|
|
||||||
#type=sha
|
|
||||||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v7
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
pull: true
|
|
||||||
|
|||||||
+14
-13
@@ -1,19 +1,20 @@
|
|||||||
FROM "ubuntu:18.04"
|
FROM ubuntu:26.04
|
||||||
LABEL maintainer="Julien Cabillot <dockerimages@cabillot.eu>"
|
LABEL maintainer="Julien Cabillot <dockerimages@cabillot.eu>"
|
||||||
|
|
||||||
RUN export DEBIAN_FRONTEND="noninteractive" && \
|
# hadolint ignore=DL3008,SC3009,SC2086,DL3009
|
||||||
export RUNTIME_PACKAGES="sslscan" && \
|
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||||
|
export RUNTIME_PACKAGES=sslscan && \
|
||||||
apt-get -qq update && \
|
apt-get -qq update && \
|
||||||
apt-get -qq --yes install ${RUNTIME_PACKAGES} && \
|
apt-get -qq --no-install-recommends --yes install ${RUNTIME_PACKAGES} && \
|
||||||
apt-get -qq --yes autoremove --purge && \
|
apt-get -qq --yes autoremove --purge && \
|
||||||
apt-get -qq --yes clean all && \
|
apt-get -qq --yes clean all && \
|
||||||
rm -rf "/usr/share/doc/"* \
|
rm -rf /usr/share/doc/* \
|
||||||
"/usr/src/"* \
|
/usr/src/* \
|
||||||
"/var/cache/"* \
|
/var/cache/* \
|
||||||
"/var/lib/apt/lists/"* \
|
/var/lib/apt/lists/* \
|
||||||
"/var/log/"{apt/*,dpkg.log} \
|
/var/log/apt \
|
||||||
"/tmp/"*
|
/var/log/dpkg.log \
|
||||||
|
/tmp/*
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/bin/sslscan" ]
|
||||||
ENTRYPOINT ["/usr/bin/sslscan"]
|
CMD [ "--help" ]
|
||||||
CMD ["--help"]
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
IMAGE="$1"
|
||||||
|
FAILED=0
|
||||||
|
PASSED=0
|
||||||
|
|
||||||
|
# Test 1: container runs and exits
|
||||||
|
if docker run --rm "$IMAGE" --help > /dev/null 2>&1; then
|
||||||
|
echo "PASS: container runs successfully"
|
||||||
|
PASSED=$((PASSED + 1))
|
||||||
|
else
|
||||||
|
echo "FAIL: container failed to run"
|
||||||
|
FAILED=$((FAILED + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test 2: produces output
|
||||||
|
OUTPUT=$(docker run --rm "$IMAGE" --version 2>&1)
|
||||||
|
if [ -n "$OUTPUT" ]; then
|
||||||
|
echo "PASS: produces output"
|
||||||
|
PASSED=$((PASSED + 1))
|
||||||
|
else
|
||||||
|
echo "FAIL: no output"
|
||||||
|
FAILED=$((FAILED + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "$PASSED/$((PASSED + FAILED)) tests passed"
|
||||||
|
if [ "$FAILED" -gt 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user