Skip to content

Build and Push PDO Docker Images #6

Build and Push PDO Docker Images

Build and Push PDO Docker Images #6

Workflow file for this run

#
# SPDX-License-Identifier: Apache-2.0
#
# This workflow will generate docker images for the
# current branch and push those images into the
# repository owners resources.
name: Build and Push PDO Docker Images
on:
workflow_dispatch:
# This section is commented out for the moment until a
# reasonable policy is determined for automated generation.
# The conditional execution must be evaluated as well. These
# are left here to serve as potential documentation for how
# the policy may be implemented.
# pull_request:
# types: [closed]
# branches: [main]
jobs:
docker_build:
# if: >
# github.event.name == 'workflow_dispatch' ||
# github.event.name == 'pull_request' && github.event.pull_request.merged == true
name: Build PDO Images
runs-on: ubuntu-22.04
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
fetch-tags: true
- name: Display branch name
run: |
echo "Building branch images for $GITHUB_HEAD_REF"
echo PDO VERSION is $(bin/get_version)
echo "PDO_VERSION=$(bin/get_version)" >> $GITHUB_ENV
echo "EVENT NAME: ${{ github.event.name }}"
echo "MERGED: ${{ github.event.pull_request.merged }}"
# create the docker images with the user and group IDs
# set to 55172 (randomly chosen number unlikely to conflict
# with existing users). this helps to set permissions local
# file management with pulled images. Specifically, the
# following will make the xfer directory writeable by the
# images:
# sudo chown -R 55172:55172 $PDO_SOURCE_ROOT/docker/xfer
- name: Build Docker Images
env:
PDO_INTERPRETER: wawaka
PDO_LOG_LEVEL: warning
run: |
git checkout -b ci-test-branch
. build/common-config.sh
make -C docker PDO_USER_UID=55172 PDO_GROUP_UID=55172
- name: Login to the ghcr.io Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and push the images
env:
OWNER: ${{ github.repository_owner }}
run: |
echo "Push images to ghcr.io/$OWNER"
for image in pdo_services pdo_ccf pdo_client
do
docker image tag $image:$PDO_VERSION ghcr.io/$OWNER/$image:$PDO_VERSION
docker image tag $image:$PDO_VERSION ghcr.io/$OWNER/$image:latest
docker image push --all-tags ghcr.io/$OWNER/$image
done