From 8ceef42ad428b64a890b314dbac03db7f5085273 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Wed, 3 Feb 2021 19:41:11 +1100 Subject: [PATCH] ci(docker): Publish Docker Image on Release --- .github/workflows/docker.yml | 42 ++++++++++++++++++++ .github/workflows/linux-build-on-release.yml | 3 +- .github/workflows/win-build-on-release.yml | 3 +- 3 files changed, 46 insertions(+), 2 deletions(-) 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..77a8313 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,42 @@ +name: Publish Docker Image + +on: + push: + tags: + - '*.*.*' + - '!*.*.*-*' + +jobs: + docker-publish: + runs-on: ubuntu-latest + steps: + # https://stackoverflow.com/questions/58177786 + - name: Get version + run: echo "GIT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push to Docker Hub + uses: docker/build-push-action@v2 + with: + push: true + tags: | + n1try/wakapi:${{ env.GIT_TAG }} + n1try/wakapi:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/linux-build-on-release.yml b/.github/workflows/linux-build-on-release.yml index 73374cc..8a3b891 100644 --- a/.github/workflows/linux-build-on-release.yml +++ b/.github/workflows/linux-build-on-release.yml @@ -2,10 +2,11 @@ name: Build Wakapi on Linux on: push: + branches: pull_request: release: types: - - created + - published jobs: build-and-release: diff --git a/.github/workflows/win-build-on-release.yml b/.github/workflows/win-build-on-release.yml index 3d66edd..73bb5e9 100644 --- a/.github/workflows/win-build-on-release.yml +++ b/.github/workflows/win-build-on-release.yml @@ -2,10 +2,11 @@ name: Build Wakapi on Windows on: push: + branches: pull_request: release: types: - - created + - published jobs: build-and-release: