Build Monorepo Base Images #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Monorepo Base Images | |
on: | |
workflow_dispatch: | |
jobs: | |
setup-environment: | |
name: Setup environment | |
runs-on: ubuntu-latest | |
outputs: | |
registry: ${{ steps.docker-environment.outputs.registry }} | |
repository: ${{ steps.docker-environment.outputs.repository }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup Watod Environment | |
run: | | |
MODULES_DIR="$GITHUB_WORKSPACE/modules" | |
. ./watod_scripts/watod-setup-env.sh | |
shell: bash | |
- name: Generate Docker Environment | |
id: docker-environment | |
uses: "./.github/templates/docker_context" | |
base-matrix-prep: | |
name: Prepare Base Image Matrix JSON | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.prep.outputs.matrix }} | |
auth_users: ${{ steps.prep.outputs.auth_users }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Setup Base Image Matrix and Auth | |
id: prep | |
run: | | |
MATRIX=$(jq -c . .github/include/base_image_config.json) | |
echo "Base Image Matrix: $MATRIX" | |
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT | |
build: | |
name: Build Base Images | |
runs-on: ubuntu-latest | |
needs: [ setup-environment, base-matrix-prep ] | |
env: | |
DOCKER_REGISTRY: ${{ needs.setup-environment.outputs.registry }} | |
DOCKER_REPOSITORY: ${{ needs.setup-environment.outputs.repository }} | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.base-matrix-prep.outputs.matrix) }} | |
concurrency: | |
group: ${{ matrix.tag }}-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
# Initial workflow setup | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Construct Registry URL | |
id: construct-registry-url | |
run: | | |
echo "url=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}/base:${{ matrix.tag }}" \ | |
>> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
id: buildx | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ secrets.GHCR_USER }} | |
password: ${{ secrets.GHCR_PWD }} | |
- name: Inject ROS2 into Image | |
if: ${{ matrix.injections.ros2 != '' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: docker/base/inject_ros2.Dockerfile | |
push: true | |
tags: | | |
${{ steps.construct-registry-url.outputs.url }}_generic | |
builder: ${{ steps.buildx.outputs.name }} | |
target: devel | |
build-args: | | |
GENERIC_IMAGE=${{ matrix.external_image }} | |
ROS_DISTRO=${{ matrix.injections.ros2 }} | |
- name: Prepare Generic Image as Monorepo Base Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: docker/base/inject_wato_base.Dockerfile | |
push: true | |
tags: | | |
${{ steps.construct-registry-url.outputs.url }} | |
builder: ${{ steps.buildx.outputs.name }} | |
target: wato_base | |
build-args: | | |
GENERIC_IMAGE=${{ steps.construct-registry-url.outputs.url }}_generic | |
USER_PASSWD=${{ secrets.MONOREPO_PASSWD }} |