From 8786993871d62a0a21d3bf93861bd554361164a9 Mon Sep 17 00:00:00 2001 From: Yves Date: Wed, 20 Dec 2023 10:55:38 +0100 Subject: [PATCH] Add Github Action workflow to automatically deploy Actions to roboto when pushed to dev --- .github/workflows/deploy.yml | 58 ++++++++++++++++++++++ actions/px4_flight_review/Dockerfile | 1 + actions/px4_flight_review/scripts/setup.sh | 3 ++ 3 files changed, 62 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..9dfb76d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,58 @@ +name: Deploy Workflow + +on: + push: + branches: + - dev + +jobs: + prepare-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + has-changes: ${{ steps.set-matrix.outputs.has-changes }} + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + fetch-depth: 0 # Fetch all history for all branches and tags + + - id: set-matrix + run: | + changed_dirs=$(git diff --name-only HEAD^ HEAD | grep '^actions/' | cut -d'/' -f1-2 | uniq) + if [ -z "$changed_dirs" ]; then + echo "::set-output name=has-changes::false" + else + matrix=$(echo "$changed_dirs" | jq -R -s -c 'split("\n")[:-1]') + echo "::set-output name=matrix::$matrix" + echo "::set-output name=has-changes::true" + fi + + build-and-deploy: + needs: prepare-matrix + runs-on: ubuntu-latest + if: needs.prepare-matrix.outputs.has-changes == 'true' + strategy: + fail-fast: false + matrix: + action: ${{fromJson(needs.prepare-matrix.outputs.matrix)}} + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Set up Roboto Config + run: | + mkdir -p ~/.roboto + echo '${{ secrets.ROBOTO_CONFIG }}' > ~/.roboto/config.json + - name: Run setup script + run: ${{ matrix.action }}/scripts/setup.sh + - name: Run build script + run: ${{ matrix.action }}/scripts/build.sh + - name: Run test script + run: sudo ${{ matrix.action }}/scripts/test.sh + - name: Run deploy script + run: ${{ matrix.action }}/scripts/deploy.sh roboto-public diff --git a/actions/px4_flight_review/Dockerfile b/actions/px4_flight_review/Dockerfile index a474735..39b58e6 100644 --- a/actions/px4_flight_review/Dockerfile +++ b/actions/px4_flight_review/Dockerfile @@ -8,6 +8,7 @@ ENV DEBIAN_FRONTEND noninteractive ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 + # Install dependencies required for Python 3.10 RUN apt-get update && \ apt-get install -y software-properties-common && \ diff --git a/actions/px4_flight_review/scripts/setup.sh b/actions/px4_flight_review/scripts/setup.sh index 20cb740..af43eb2 100755 --- a/actions/px4_flight_review/scripts/setup.sh +++ b/actions/px4_flight_review/scripts/setup.sh @@ -10,6 +10,9 @@ venv_dir="$PACKAGE_ROOT/.venv" # Create a virtual environment python -m venv --upgrade-deps $venv_dir +# Initialize flight review submodule +#git submodule update --init --recursive $PACKAGE_ROOT/src/px4_flight_review/flight_review/ + # Install roboto pip_exe="$venv_dir/bin/pip" $pip_exe install --upgrade -r $PACKAGE_ROOT/requirements.dev.txt