Skip to content

Build and push container images #35

Build and push container images

Build and push container images #35

Workflow file for this run

# Copyright 2023 The Cross-Media Measurement Authors
#
# Licensed 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 and push container images
on:
workflow_dispatch:
workflow_call:
outputs:
image-tag:
description: "Tag of container images"
value: ${{ jobs.push-images.outputs.image-tag }}
jobs:
push-images:
runs-on: ubuntu-20.04
outputs:
image-tag: ${{ steps.get-image-tag.outputs.image-tag }}
env:
CONTAINER_REGISTRY: ghcr.io
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/free-disk-space
- id: get-image-tag
name: Get image tag
run: |
declare image_tag
if [[ "$GITHUB_REF_TYPE" == 'tag' ]]; then
image_tag="${GITHUB_REF_NAME#v}"
else
image_tag="$GITHUB_SHA"
fi
echo "image-tag=${image_tag}" >> "$GITHUB_OUTPUT"
- name: Write ~/.bazelrc
env:
IMAGE_TAG: ${{ steps.get-image-tag.outputs.image-tag }}
run: |
cat << EOF > ~/.bazelrc
build -c opt
build --host_platform //build/platforms:ubuntu_20_04
build --define container_registry=$CONTAINER_REGISTRY
build --define image_repo_prefix=$GITHUB_REPOSITORY_OWNER
build --define image_tag=$IMAGE_TAG
EOF
- name: Get Bazel cache params
id: get-cache-params
uses: world-federation-of-advertisers/actions/bazel-get-cache-params@v2
with:
cache-version: 1
- name: Restore Bazel cache
uses: actions/cache/restore@v3
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}
restore-keys: |-
${{ steps.get-cache-params.outputs.restore-key }}
- name: Authenticate to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build images
run: >
bazelisk build
//src/main/docker:push_all_gke_images
//src/main/docker/panel_exchange_client:push_all_images
//src/main/docker:push_all_eks_images
- name: Push images
run: |
bazelisk run //src/main/docker:push_all_gke_images
bazelisk run //src/main/docker/panel_exchange_client:push_all_images
bazelisk run //src/main/docker:push_all_eks_images