Skip to content

disable push

disable push #103

Workflow file for this run

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: build
on:
pull_request:
types: [opened, ready_for_review, synchronize]
push:
env:
VERSION: ${{ github.sha }}
jobs:
build:
name: build and deploy
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Calculate image name in owner/repo format
id: names
run: |
owner="$(echo ${{ github.repository_owner }} | tr '[A-Z]' '[a-z]')"
echo "image_id=$owner/$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/ozone-runner
tags: |
type=ref,event=tag
type=sha,prefix=,format=long
- name: Check if image exists
id: pull
run: |
success=false
if docker pull "ghcr.io/$IMAGE_ID:$VERSION"; then
success=true
fi
echo "success=$success" >> $GITHUB_OUTPUT
env:
IMAGE_ID: ${{ steps.names.outputs.image_id }}
continue-on-error: true
- name: Set up QEMU
if: ${{ steps.pull.outputs.success != 'true' }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ steps.pull.outputs.success != 'true' }}
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
if: ${{ github.event_name == 'push' }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and push multi-platform image
if: ${{ steps.pull.outputs.success != 'true' }}
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Apply tag to existing image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' && steps.pull.outputs.success == 'true' }}
run: |
docker tag "ghcr.io/$IMAGE_ID:$VERSION" "ghcr.io/$IMAGE_ID:$TAG"
docker push "ghcr.io/$IMAGE_ID:$TAG"
env:
IMAGE_ID: ${{ steps.names.outputs.image_id }}
TAG: ${{ github.ref_name }}
- name: Logout
if: always()
run: |
docker logout