name: Release on: workflow_dispatch: release: types: [published] jobs: build: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci-skip]')" steps: - name: Checkout uses: actions/checkout@v2 - name: Prepare id: prep run: | DOCKER_IMAGE=phusion/baseimage GIT_BRANCH=${GITHUB_REF##*/} # Set the platforms to build for here and thus reduce duplicating it. PLATFORMS=amd64,arm,arm64 TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}, ghcr.io/${{ github.repository_owner }}/baseimage:${GIT_BRANCH}" # Set output parameters. if [ "${{github.event_name}}" == "pull_request" ]; then echo "push=false" >> $GITHUB_OUTPUT else echo "push=true" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT echo "branch=${GIT_BRANCH}" >> $GITHUB_OUTPUT echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT fi echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v1 with: platforms: ${{ steps.prep.outputs.platforms }} - name: Login to GHCR (Github Container Registry) uses: docker/login-action@v1 if: github.event_name != 'pull_request' with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 with: install: true version: latest driver-opts: image=moby/buildkit:latest - name: Login to Docker Hub if: github.event_name != 'pull_request' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and Push uses: docker/build-push-action@v2 with: builder: ${{ steps.buildx.outputs.name }} context: image platforms: ${{ steps.prep.outputs.platforms }} push: ${{ steps.prep.outputs.push }} tags: ${{ steps.prep.outputs.tags }}