Unify CI to prepare for other ROS distros #1
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: Deploy Opensource Image to GHCR | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
generate_matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
- name: "Parse images.json" | |
id: set-matrix | |
run: echo "matrix=$(cat .github/workflows/ci_images.json)" >> $GITHUB_OUTPUT | |
build: | |
needs: generate_matrix | |
runs-on: ubuntu-latest | |
permissions: write-all | |
strategy: | |
matrix: ${{fromJson(needs.generate_matrix.outputs.matrix)}} | |
fail-fast: false | |
steps: | |
- name: "Checkout GitHub Action" | |
uses: actions/checkout@v4 | |
- name: "Login to GitHub Container Registry" | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: "Build the Docker images" | |
run: | | |
echo "Building ${{ matrix.TAG }}" | |
IMAGE_TAG="ghcr.io/simonschwaiger/ros-ml-container:${{ matrix.TAG }}" | |
mkdir src | |
echo "jupyterlab" > requirements.txt | |
docker build . --file .github/workflows/{{ matrix.DOCKERFILE }} --tag $IMAGE_TAG --build-arg BASEIMAGE=${{ matrix.BASEIMAGE }} --build-arg ROS_DISTRO=${{ matrix.ROS_DISTRO }} --build-arg PYTHONVER=${{ matrix.PYTHONVER }} | |
docker push $IMAGE_TAG |