From ba78fcfa9665f84d1519fa6242ba01e7f2f197f6 Mon Sep 17 00:00:00 2001 From: Helen Oleynikova Date: Thu, 10 Aug 2023 15:13:52 +0200 Subject: [PATCH] Split into CI CD --- .github/workflows/{moma.yml => cd.yml} | 3 +- .github/workflows/ci.yml | 125 +++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) rename .github/workflows/{moma.yml => cd.yml} (97%) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/moma.yml b/.github/workflows/cd.yml similarity index 97% rename from .github/workflows/moma.yml rename to .github/workflows/cd.yml index 3eb1f751..08bc95e2 100644 --- a/.github/workflows/moma.yml +++ b/.github/workflows/cd.yml @@ -1,4 +1,4 @@ -name: moma CI & Docker +name: moma CD on: push: @@ -11,7 +11,6 @@ env: REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} - CATKIN_WS_PATH: /__w/moma/moma/moma_ws jobs: build-docker: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c62ac460 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,125 @@ +name: moma CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + CATKIN_WS_PATH: moma_ws + +jobs: + build-dev: + name: Build dev docker image + runs-on: ubuntu-latest + outputs: + docker_image_name: ${{ steps.meta.outputs.tags }} + steps: + - name: Check out moma repo + uses: actions/checkout@v3 + with: + path: moma_ws/src/moma + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: prefix=dev + - name: Build and push docker + uses: docker/build-push-action@v4 + with: + context: ./moma_ws/src/moma/docker/ + file: ./moma_ws/src/moma/docker/dev.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-robot: + name: Build robot docker image + runs-on: ubuntu-latest + outputs: + docker_image_name: ${{ steps.meta.outputs.tags }} + steps: + - name: Check out moma repo + uses: actions/checkout@v3 + with: + path: moma_ws/src/moma + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: prefix=robot + - name: Build and push docker + uses: docker/build-push-action@v4 + with: + context: ./moma_ws/src/moma/docker/ + file: ./moma_ws/src/moma/docker/robot.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Checks out the demo branch and builds a docker image of that. + build-demo: + name: Build robot docker image + runs-on: ubuntu-latest + outputs: + docker_image_name: ${{ steps.meta.outputs.tags }} + steps: + - name: Check out moma repo + uses: actions/checkout@v3 + with: + ref: demo + path: moma_ws/src/moma + submodules: recursive + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: prefix=demo + - name: Build and push docker + uses: docker/build-push-action@v4 + with: + context: ./moma_ws/src/moma/docker/ + file: ./moma_ws/src/moma/docker/demo.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max