From a4df41bf815ada17f66d3d6880857fad8a909b78 Mon Sep 17 00:00:00 2001 From: omg-xtao <100690902+omg-xtao@users.noreply.github.com> Date: Fri, 10 Feb 2023 22:41:12 +0800 Subject: [PATCH] Create docker.yml --- .github/workflows/docker.yml | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..59cbc23 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,49 @@ +name: "Docker Build" + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + workflow_dispatch: ~ + push: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + name: docker build and publish + env: + DOCKER_BUILDKIT: 1 + DOCKER_CLI_EXPERIMENTAL: enabled + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKERHUB_REPOSITORY: ${{ secrets.DOCKER_REPO }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Setup Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Buildx cache + uses: actions/cache@v2 + id: buildx-cache + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx + + - name: Build + run: | + docker buildx build \ + --cache-from "type=local,src=/tmp/.buildx-cache" \ + --cache-to "type=local,dest=/tmp/.buildx-cache" \ + --output "type=image,push=true" \ + --platform "linux/amd64,linux/arm64/v8" \ + --build-arg "S6_ARCH=amd64" \ + --tag "${DOCKERHUB_REPOSITORY}:latest" \ + -f Dockerfile \ + .