From 2bf2784dfc931e0ac52a85a628a28eb546d94de5 Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Sat, 12 Dec 2020 23:32:42 +0100 Subject: [PATCH] CI/CD: Build the Docker images with GitHub Actions (#13) --- .github/workflows/autotag.yml | 20 +++++++++++++ .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/autotag.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/autotag.yml b/.github/workflows/autotag.yml new file mode 100644 index 0000000..fc8895a --- /dev/null +++ b/.github/workflows/autotag.yml @@ -0,0 +1,20 @@ +name: autotag + +on: + push: + branches: + - "master" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Auto Tag + uses: Klemensas/action-autotag@stable + with: + GITHUB_TOKEN: "${{ secrets.GH_PAT }}" + tag_prefix: "v" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..987a689 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: build + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Downcase repo + run: echo REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + - + name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ${{ env.REPOSITORY }},ghcr.io/${{ env.REPOSITORY }} + tag-sha: true + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + 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: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_PAT }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }}