zabetak commented on code in PR #6953:
URL: https://github.com/apache/hive/pull/6953#discussion_r4554021080


##########
.github/workflows/precommit-image.yml:
##########
@@ -0,0 +1,100 @@
+# 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.
+
+# Builds the precommit image (dev-support/docker/ci/runner). On master it 
publishes the image as
+# apache/hive-ci-runner:<version>, with the org.opencontainers.image.version 
of the Dockerfile. The
+# Jenkinsfile pins that tag. A published tag is never overwritten.
+name: Precommit image
+
+on:
+  pull_request:
+    paths:
+      - 'dev-support/docker/ci/runner/Dockerfile'
+      - '.github/workflows/precommit-image.yml'
+  push:
+    branches:
+      - master
+    paths:
+      - 'dev-support/docker/ci/runner/Dockerfile'
+      - '.github/workflows/precommit-image.yml'
+  workflow_dispatch:
+    inputs:
+      tag:
+        description: 'Tag to publish a candidate under (e.g. HIVE-12345), to 
try it with the IMAGE parameter of the precommit job; it must not exist yet'
+        required: true
+
+permissions:
+  contents: read
+
+jobs:
+  build:
+    # On a fork, a push to master only syncs apache/hive: there is nothing to 
publish.
+    if: github.event_name != 'push' || github.repository == 'apache/hive'
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v6
+        with:
+          persist-credentials: false
+
+      - name: Check that the tag is not published yet
+        id: tag
+        env:
+          INPUT_TAG: ${{ github.event.inputs.tag }}
+        run: |
+          version=$(sed -n 's/^LABEL 
org.opencontainers.image.version="\(.*\)"$/\1/p' 
dev-support/docker/ci/runner/Dockerfile)
+          image=apache/hive-ci-runner:${INPUT_TAG:-$version}
+          if [[ $image == *: ]]; then
+            echo "::error::No org.opencontainers.image.version label in the 
Dockerfile"
+            exit 1
+          fi
+          if docker manifest inspect "$image" > /dev/null 2>&1; then
+            echo "::error::$image is already published, and a published tag is 
never overwritten. Bump org.opencontainers.image.version in the Dockerfile (or 
pick another tag for a manual run)."
+            exit 1
+          fi

Review Comment:
   We can disable tag overwrite directly in DockerHub if we want to.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to