From 1fcac8791ad9f761b1c1767d4f8b18ec44bf8699 Mon Sep 17 00:00:00 2001 From: Jauder Ho Date: Mon, 9 Aug 2021 11:44:05 +0000 Subject: [PATCH 1/4] Use GH Action to build Docker images --- .github/workflows/docker-3.0.yml | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docker-3.0.yml diff --git a/.github/workflows/docker-3.0.yml b/.github/workflows/docker-3.0.yml new file mode 100644 index 0000000..1264f8d --- /dev/null +++ b/.github/workflows/docker-3.0.yml @@ -0,0 +1,63 @@ +name: docker-3.0 + +on: + push: + branches: + - 3.0 + workflow_dispatch: + schedule: + - cron: "0 8 * * 1" + +env: + BUILD_VERSION: "3.0" + DOCKER_CLI_EXPERIMENTAL: enabled + REPOSITORY: ${{ github.actor }}/testssl.sh + +jobs: + + deploy: + runs-on: ubuntu-20.04 + + steps: + - name: Source checkout + uses: actions/checkout@v2.3.4 + + - name: Setup QEMU + id: qemu + uses: docker/setup-qemu-action@v1.2.0 + + - name: Setup Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Set Docker metadata + id: docker_meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REPOSITORY }} + labels: | + org.opencontainers.image.version=${{ env.BUILD_VERSION }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.title=${{ env.REPOSITORY }} + + - name: GitHub login + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v1.10.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2.6.1 + with: + push: ${{ github.event_name != 'pull_request' }} + context: . + file: Dockerfile.git + platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le + build-args: BUILD_VERSION + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} + labels: ${{ steps.docker_meta.outputs.labels }} + tags: | + ghcr.io/${{ env.REPOSITORY }}:${{ env.BUILD_VERSION }} From 63722babe9c571629b40a3824ca64175e6bc81a6 Mon Sep 17 00:00:00 2001 From: Jauder Ho Date: Mon, 9 Aug 2021 11:45:33 +0000 Subject: [PATCH 2/4] Add missing file --- Dockerfile.git | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile.git diff --git a/Dockerfile.git b/Dockerfile.git new file mode 100644 index 0000000..50106a3 --- /dev/null +++ b/Dockerfile.git @@ -0,0 +1,24 @@ +# Build using git repo + +FROM alpine:3.14 + +WORKDIR /home/testssl + +ARG BUILD_VERSION +ARG ARCHIVE_URL=https://github.com/drwetter/testssl.sh/archive/ +ARG URL=https://github.com/drwetter/testssl.sh.git + +RUN test -n "${BUILD_VERSION}" \ + && apk update \ + && apk add --no-cache bash procps drill git coreutils libidn curl socat openssl xxd \ + && git clone --depth 1 --branch ${BUILD_VERSION} $URL /home/testssl \ + && addgroup testssl \ + && adduser -G testssl -g "testssl user" -s /bin/bash -D testssl \ + && ln -s /home/testssl/testssl.sh /usr/local/bin/ \ + && mkdir -m 755 -p /home/testssl/etc /home/testssl/bin + +USER testssl + +ENTRYPOINT ["testssl.sh"] + +CMD ["--help"] From b04745d960c5fbdd175afe17aca58a08b6ef5446 Mon Sep 17 00:00:00 2001 From: Jauder Ho Date: Mon, 9 Aug 2021 11:53:48 +0000 Subject: [PATCH 3/4] Use github.repository instead --- .github/workflows/docker-3.0.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-3.0.yml b/.github/workflows/docker-3.0.yml index 1264f8d..5090a32 100644 --- a/.github/workflows/docker-3.0.yml +++ b/.github/workflows/docker-3.0.yml @@ -34,11 +34,11 @@ jobs: id: docker_meta uses: docker/metadata-action@v3 with: - images: ${{ env.REPOSITORY }} + images: ${{ github.repository }} labels: | org.opencontainers.image.version=${{ env.BUILD_VERSION }} org.opencontainers.image.revision=${{ github.sha }} - org.opencontainers.image.title=${{ env.REPOSITORY }} + org.opencontainers.image.title=${{ github.repository }} - name: GitHub login if: ${{ github.event_name != 'pull_request' }} @@ -60,4 +60,4 @@ jobs: cache-to: type=gha, scope=${{ github.workflow }} labels: ${{ steps.docker_meta.outputs.labels }} tags: | - ghcr.io/${{ env.REPOSITORY }}:${{ env.BUILD_VERSION }} + ghcr.io/${{ github.repository }}:${{ env.BUILD_VERSION }} From 86543ecab5b64e7c0b30b9b48d80e56eff64063b Mon Sep 17 00:00:00 2001 From: Jauder Ho Date: Mon, 9 Aug 2021 11:59:19 +0000 Subject: [PATCH 4/4] Cleanup --- .github/workflows/docker-3.0.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-3.0.yml b/.github/workflows/docker-3.0.yml index 5090a32..da7a0e0 100644 --- a/.github/workflows/docker-3.0.yml +++ b/.github/workflows/docker-3.0.yml @@ -11,7 +11,6 @@ on: env: BUILD_VERSION: "3.0" DOCKER_CLI_EXPERIMENTAL: enabled - REPOSITORY: ${{ github.actor }}/testssl.sh jobs: