diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af2f517..5d36475 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,20 +19,31 @@ jobs: id: prep run: | DOCKER_IMAGE=phusion/baseimage - VERSION=focal-test GIT_BRANCH=${GITHUB_REF##*/} - TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}" + TAGS="${DOCKER_IMAGE}:${GIT_BRANCH}, ghcr.io/${{ github.repository_owner }}/baseimage:${GIT_BRANCH}" # Set output parameters. - echo ::set-output name=tags::${TAGS} - echo ::set-output name=branch::${GIT_BRANCH} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - + if [ "${{github.event_name}}" == "pull_request" ]; then + echo ::set-output name=push::false + else + echo ::set-output name=tags::${TAGS} + echo ::set-output name=branch::${GIT_BRANCH} + echo ::set-output name=docker_image::${DOCKER_IMAGE} + fi + - name: Set up QEMU uses: docker/setup-qemu-action@v1 with: platforms: amd64,arm64 + + - 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 @@ -41,6 +52,7 @@ jobs: install: true version: latest driver-opts: image=moby/buildkit:latest + - name: Login to Docker Hub if: github.event_name != 'pull_request' @@ -52,9 +64,8 @@ jobs: - name: Build and Push uses: docker/build-push-action@v2 with: - build-args: VERSION=focal-1.0.0-test builder: ${{ steps.buildx.outputs.name }} context: image platforms: amd64,arm64 - push: true + push: ${{ steps.prep.outputs.push }} tags: ${{ steps.prep.outputs.tags }}