From 2c9ef1fe1f8b900efe501cd56ed0d4f2659043a9 Mon Sep 17 00:00:00 2001 From: Christian Prather Date: Wed, 16 Aug 2023 14:00:48 -0600 Subject: [PATCH] Added action and bash script --- .github/workflows/deploy-docker.yml | 57 +++++++++++++++++++++++++++++ build-and-deploy-dockers.sh | 27 ++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/deploy-docker.yml create mode 100755 build-and-deploy-dockers.sh diff --git a/.github/workflows/deploy-docker.yml b/.github/workflows/deploy-docker.yml new file mode 100644 index 0000000..11fced5 --- /dev/null +++ b/.github/workflows/deploy-docker.yml @@ -0,0 +1,57 @@ +name: Create and Deploy Docker + +on: + workflow_dispatch: + inputs: + DEV: + type: boolean + description: "If the DEV image should be build" + required: true + default: false + RELEASE: + type: boolean + description: "If the public RELEASE image should be build" + required: true + default: false + + +env: + REPO: ${{github.event.repository.name}} + JF_URL: ${{ secrets.JF_URL }} + JF_ACCESS_TOKEN: ${{ secrets.artifactory_token}} + +jobs: + Build-and-deploy-dev: + runs-on: ubuntu-latest + steps: + - uses: jfrog/setup-jfrog-cli@v3 + + - name: Checkout SDK Branch + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + path: ${{env.REPO}} + + - name: Build and deploy dev + if: ${{ github.event.inputs.DEV == 'true'}} + run: | + cd ${{env.REPO}} + ./build-and-deploy-dockers.sh -d + shell: bash + + Build-and-deploy-release: + runs-on: ubuntu-latest + steps: + - uses: jfrog/setup-jfrog-cli@v3 + - name: Checkout SDK Branch + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + path: ${{env.REPO}} + + - name: Build and deploy release + if: ${{ github.event.inputs.RELEASE == 'true' }} + run: | + cd ${{env.REPO}} + ./build-and-deploy-dockers.sh -r + shell: bash diff --git a/build-and-deploy-dockers.sh b/build-and-deploy-dockers.sh new file mode 100755 index 0000000..1196c1b --- /dev/null +++ b/build-and-deploy-dockers.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +while getopts 'dr' flag; +do + case "${flag}" in + d) development=true;; + r) release=true;; + esac +done + +if [ "$development" = true ]; then + echo "Development building..." + cd development + # Build development image + docker build -t luci.jfrog.io/ros2-sdk-docker-local/luci-sdk-development-image:latest . + # Push development image to jfrog + docker push luci.jfrog.io/ros2-sdk-docker-local/luci-sdk-development-image:latest +fi + +if [ "$release" = true ]; then + echo "Release building..." + + # Build release image + docker build -t luci.jfrog.io/ros2-sdk-docker-local/luci-ros2-sdk:latest . + # Push release image to jfrog + docker push luci.jfrog.io/ros2-sdk-docker-local/luci-ros2-sdk:latest +fi \ No newline at end of file