index : static-web-server.git

ascending towards madness

name: release-docker
on:
  release:
    types:
      - published

jobs:
  docker-image-alpine:
    runs-on: ubuntu-22.04
    if: contains(github.ref, 'v2.')
    steps:
      -
        name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        name: Docker meta alpine
        id: meta_alpine
        uses: docker/metadata-action@v4
        with:
          images: |
            joseluisq/static-web-server
            ghcr.io/static-web-server/static-web-server
          flavor: |
            latest=false
            suffix=-alpine
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
      -
        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: Prepare Docker envs
        shell: bash
        run: |
          echo "SERVER_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV
      -
        name: Build and push (alpine)
        uses: docker/build-push-action@v4
        with:
          push: true
          context: .
          platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6
          file: ./docker/alpine/Dockerfile
          tags: ${{ steps.meta_alpine.outputs.tags }}
          build-args: |
            SERVER_VERSION=${{ env.SERVER_VERSION }}

  docker-image-debian:
    needs: ['docker-image-alpine']
    runs-on: ubuntu-22.04
    if: contains(github.ref, 'v2.')
    steps:
      -
        name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        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
            suffix=-debian
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
      -
        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: Prepare Docker envs
        shell: bash
        run: |
          echo "SERVER_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV
      -
        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.SERVER_VERSION }}

  docker-image-scratch:
    needs: ['docker-image-alpine']
    runs-on: ubuntu-22.04
    steps:
      -
        name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        name: Docker meta scratch
        id: meta_scratch
        uses: docker/metadata-action@v4
        with:
          images: |
            joseluisq/static-web-server
            ghcr.io/static-web-server/static-web-server
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
      -
        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: Prepare Docker envs
        shell: bash
        run: |
          echo "SERVER_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV
      -
        name: Build and push (scratch)
        uses: docker/build-push-action@v4
        with:
          push: true
          context: .
          platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6
          file: ./docker/scratch/Dockerfile
          tags: ${{ steps.meta_scratch.outputs.tags }}
          build-args: |
            SERVER_VERSION=${{ env.SERVER_VERSION }}