From 3099dba4d3bdc7faf55a7dded27fcd6d02a8b4f7 Mon Sep 17 00:00:00 2001 From: Jose Quintana <1700322+joseluisq@users.noreply.github.com> Date: Fri, 10 Nov 2023 22:52:33 +0100 Subject: [PATCH] chore: docker ci workflow (Debian) (#286) --- .github/workflows/devel.docker.yml | 12 +++++++++--- .github/workflows/devel.yml | 7 +++++++ .github/workflows/release.docker.manual.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ docker/debian/Dockerfile | 10 ++++++++-- 4 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.docker.manual.yml diff --git a/.github/workflows/devel.docker.yml b/.github/workflows/devel.docker.yml index 755ac63..15afc99 100644 --- a/.github/workflows/devel.docker.yml +++ b/.github/workflows/devel.docker.yml @@ -1,14 +1,20 @@ name: devel-docker on: pull_request: + paths: + - docker/**/Dockerfile + - scripts/ci/**/*.sh + - .github/workflows/devel.docker.yml push: branches: - - master - - staging - - trying + - master + - staging + - trying paths: - docker/**/Dockerfile - scripts/ci/**/*.sh + - .github/workflows/devel.docker.yml + env: DOCKER_IMAGE: localhost:5000/github.com/static-web-server/static-web-server diff --git a/.github/workflows/devel.yml b/.github/workflows/devel.yml index 47e773f..a228514 100644 --- a/.github/workflows/devel.yml +++ b/.github/workflows/devel.yml @@ -1,6 +1,13 @@ name: devel on: pull_request: + paths: + - .github/workflows/devel.yml + - .cargo/config.toml + - Cargo.lock + - Cargo.toml + - src/** + - tests/** push: branches: - master diff --git a/.github/workflows/release.docker.manual.yml b/.github/workflows/release.docker.manual.yml new file mode 100644 index 0000000..547c008 --- /dev/null +++ b/.github/workflows/release.docker.manual.yml @@ -0,0 +1,75 @@ +name: release-docker-manual +on: + pull_request: + types: + - labeled + paths: + - docker/**/Dockerfile + - scripts/ci/**/*.sh + - .github/workflows/release.docker.manual.yml + +jobs: + docker-image-debian: + runs-on: ubuntu-22.04 + environment: docker-publish-manual + if: contains(github.event.label.name, 'docker:publish:v2.') + steps: + - + name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 1 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Prepare Docker envs + shell: bash + run: | + version=${{ github.event.label.name }} + semver=${version#*docker:publish:v} + echo "SEMVER=$semver" >> $GITHUB_ENV + echo "SEMVER_MAJOR=${semver%.*.*}" >> $GITHUB_ENV + echo "SEMVER_MINOR=${semver%.*}" >> $GITHUB_ENV + - + name: Docker meta debian + id: meta_debian + uses: docker/metadata-action@v4 + with: + images: | + joseluisq/static-web-server + ghcr.io/static-web-server/static-web-server + flavor: | + latest=false + tags: | + type=raw,value=debian + type=raw,value=${{ env.SEMVER }}-debian + type=raw,value=${{ env.SEMVER_MAJOR }}-debian + type=raw,value=${{ env.SEMVER_MINOR }}-debian + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to ghcr.io + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push (debian) + uses: docker/build-push-action@v4 + with: + push: true + context: . + platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x + file: ./docker/debian/Dockerfile + tags: ${{ steps.meta_debian.outputs.tags }} + build-args: | + SERVER_VERSION=${{ env.SEMVER }} diff --git a/docker/debian/Dockerfile b/docker/debian/Dockerfile index 9f0656a..6891555 100644 --- a/docker/debian/Dockerfile +++ b/docker/debian/Dockerfile @@ -37,8 +37,14 @@ RUN set -ex \ && uname -a \ && cat /etc/os-release \ && echo VERSION_NUMBER=$(cat /etc/debian_version) \ - && static-web-server --version \ - && static-web-server --help \ + && case "$TARGETPLATFORM" in \ + **ppc64*|*s390x*) \ + echo "warn: can not run sws binary on $TARGETPLATFORM architecture" ;; \ + *) \ + static-web-server --version; \ + static-web-server --help; \ + ;; \ + esac \ && file /usr/local/bin/static-web-server \ && true -- libgit2 1.7.2