From 5d40c2c9c0518528b6b4e2920895016f0bc2682c Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Mon, 8 Jun 2020 14:18:31 +0800 Subject: [PATCH] Add Actions script for building Docker images --- .github/workflows/docker.yml | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 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..6943308 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,46 @@ +name: Publish Docker Image +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Checkout base + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up docker buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v2 + with: + buildx-version: latest + skip-cache: false + qemu-version: latest + + - name: Docker login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Docker buildx image and push on master branch + if: github.ref == 'refs/heads/master' + run: | + docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag tindy2013/subconverter:latest scripts/ + + - name: Replace tag without `v` + if: startsWith(github.ref, 'refs/tags/') + uses: actions/github-script@v1 + id: version + with: + script: | + return context.payload.ref.replace(/\/refs\/tags\//v, '') + result-encoding: string + + - name: Docker buildx image and push on release + if: startsWith(github.ref, 'refs/tags/') + run: | + docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag tindy2013/subconverter:${{steps.version.outputs.result}} scripts/ + docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag tindy2013/subconverter:latest scripts/