|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Docker Image Build |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + tags: |
| 25 | + - '*' |
| 26 | + pull_request: |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 33 | + cancel-in-progress: true |
| 34 | + |
| 35 | +jobs: |
| 36 | + build: |
| 37 | + if: github.repository == 'apache/cloudstack-kubernetes-provider' |
| 38 | + runs-on: ubuntu-22.04 |
| 39 | + steps: |
| 40 | + - name: Login to Docker Registry |
| 41 | + uses: docker/login-action@v2 |
| 42 | + with: |
| 43 | + registry: ${{ secrets.DOCKER_REGISTRY }} |
| 44 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 45 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Set Docker repository name |
| 48 | + run: echo "DOCKER_REPOSITORY=apache" >> $GITHUB_ENV |
| 49 | + |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + fetch-depth: 0 |
| 53 | + |
| 54 | + - name: Set Docker image TAG |
| 55 | + run: echo "TAG=$(if [ "${{ github.event_name }}" = "pull_request" ];then echo "pr${{ github.event.pull_request.number}}"; elif [ "${{ github.ref_name }}" = "main" ];then cat version; else echo ${{ github.ref_name }};fi)" >> $GITHUB_ENV |
| 56 | + |
| 57 | + - name: Set Docker image FULL TAG |
| 58 | + run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = "" ];then echo ${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};else echo ${{ secrets.DOCKER_REGISTRY }}/${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};fi)" >> $GITHUB_ENV |
| 59 | + |
| 60 | + - name: Build the Docker image for cloudstack-kubernetes-provider |
| 61 | + run: docker build . --file Dockerfile --tag ${FULL_TAG} |
| 62 | + |
| 63 | + - name: Push Docker image to Docker Registry |
| 64 | + run: docker push ${FULL_TAG} |
0 commit comments