diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml index 3fbb6af..080b08a 100644 --- a/.github/workflows/docker-build-push.yaml +++ b/.github/workflows/docker-build-push.yaml @@ -1,34 +1,57 @@ name: Build Docker Image -on: [push] +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ main ] + tags: + - v* + pull_request: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + repository_dispatch: + types: + - webhook jobs: k8s: name: RemoteDockerImage - runs-on: ubuntu-latest + runs-on: self-hosted steps: - - id: rethinkdb - uses: pozetroninc/github-action-get-latest-release@master - with: - repository: rethinkdb/rethinkdb-dockerfiles - name: Checkout uses: actions/checkout@v2 - - - 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 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + with: + install: true + - name: Docker Login + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - uses: docker/build-push-action@v2 + # list of Docker images to use as base name for tags + images: | + ghcr.io/${{ github.repository_owner }}/base/rethinkdb + # generate Docker tags based on the following events/attributes + tags: | + type=schedule,pattern=nightly + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Build Image + uses: docker/build-push-action@v3 with: context: ./init/ - push: true file: ./init/Dockerfile - build-args: | - upstream_image=rethinkdb:${{ steps.rethinkdb.outputs.release }} - tags: pozetroninc/rethinkdb-cluster:latest, pozetroninc/rethinkdb-cluster:${{ steps.rethinkdb.outputs.release }} + push: true + pull: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + builder: ${{ steps.buildx.outputs.name }} + cache-from: type=gha + cache-to: type=gha,mode=max