From 59cda5d530028784316322f6b082c2a5bf5522ac Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Fri, 21 Jan 2022 23:45:33 +0100 Subject: [PATCH] chore: docker release --- .github/workflows/release.docker.yml | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/release.docker.yml diff --git a/.github/workflows/release.docker.yml b/.github/workflows/release.docker.yml new file mode 100644 index 0000000..7aa0fcc --- /dev/null +++ b/.github/workflows/release.docker.yml @@ -0,0 +1,97 @@ +name: release-docker +on: + release: + types: published + +jobs: + docker-image-alpine: + runs-on: ubuntu-20.04 + if: contains(github.ref, 'v1.') + steps: + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Docker meta alpine + id: meta_alpine + uses: docker/metadata-action@v3 + with: + images: joseluisq/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@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Prepare Docker envs + shell: bash + run: | + echo "SERVER_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV + echo "SERVER_DOCKERFILE=./docker/alpine/Dockerfile" >> $GITHUB_ENV + - + name: Build and push (alpine) + uses: docker/build-push-action@v2 + with: + push: true + context: . + file: ${{ env.SERVER_DOCKERFILE }} + tags: ${{ steps.meta_alpine.outputs.tags }} + build-args: | + SERVER_VERSION=${{ env.SERVER_VERSION }} + + docker-image-scratch: + needs: ['docker-image-alpine'] + if: contains(github.ref, 'v1.') + runs-on: ubuntu-20.04 + steps: + - + name: Checkout repository + uses: actions/checkout@v2 + - + name: Docker meta scratch + id: meta_scratch + uses: docker/metadata-action@v3 + with: + images: joseluisq/static-web-server + flavor: | + latest=false + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Prepare Docker envs + shell: bash + run: | + echo "SERVER_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV + echo "SERVER_DOCKERFILE=./docker/scratch/Dockerfile" >> $GITHUB_ENV + - + name: Build and push (scratch) + uses: docker/build-push-action@v2 + with: + push: true + context: . + file: ${{ env.SERVER_DOCKERFILE }} + tags: ${{ steps.meta_scratch.outputs.tags }} + build-args: | + SERVER_VERSION=${{ env.SERVER_VERSION }} -- libgit2 1.7.2