100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fix custom project CI/CD (#1554)
Wouter Born659a17e6d67a
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex 267743131..5aa628f0e 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -222,10 +222,37 @@ jobs:- name: Check if main repoid: is_main_reporun: |- if [ $GITHUB_REPOSITORY == 'openremote/openremote' ]; then+ if [ $(grep -E '.+/openremote$' <<< "$GITHUB_REPOSITORY") ]; thenecho "value=true" >> $GITHUB_OUTPUT+ else+ if [ -e 'openremote' ]; then+ echo "::error::Custom project should not have an 'openremote' file or directory!"+ exit 1+ fi++ echo "value=false" >> $GITHUB_OUTPUT+ echo "repository=$(sed -E 's#(.+)/.+#\1/openremote#' <<< $GITHUB_REPOSITORY)" >> $GITHUB_OUTPUT++ version=$(cat gradle.properties | grep openremoteVersion | sed -E 's#.+=(.+)#\1#' | xargs)+ if [ $(grep -E '.+SNAPSHOT$' <<< "$version") ]; then+ echo "ref=master" >> $GITHUB_OUTPUT+ else+ echo "ref=$version" >> $GITHUB_OUTPUT+ fifi+ - name: Checkout main repo+ uses: actions/checkout@v4+ if: ${{ steps.is_main_repo.outputs.value == 'false' }}+ with:+ repository: ${{ steps.is_main_repo.outputs.repository }}+ path: openremote+ ref: ${{ steps.is_main_repo.outputs.ref }}+ sparse-checkout: |+ .ci_cd+ profile+ sparse-checkout-cone-mode: false+- name: Check deployment build.gradleid: check_deployment_gradleuses: andstor/file-existence-action@v3@@ -238,12 +265,6 @@ jobs:with:files: "deployment/Dockerfile"- - name: Check custom project- id: check_custom_project- uses: andstor/file-existence-action@v3- with:- files: ".gitmodules"-- name: Check ci_cd existenceid: check_cicd_jsonuses: andstor/file-existence-action@v3@@ -253,12 +274,12 @@ jobs:- name: Check is custom project when scheduled triggerif: ${{ github.event_name == 'schedule' }}run: |- if [ "$IS_CUSTOM_PROJECT" != 'true' ]; then+ if [ "$IS_MAIN_REPO" == 'true' ]; thenecho "Schedule can only be used on a custom project repo"exit 1fienv:- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}# For scheduled execution from custom projects we need to be able to determine if the manager docker image has# changed since the last execution, we do this using a cache@@ -465,7 +486,7 @@ jobs:id: manager-docker-commandshell: bashrun: |- if [ $IS_CUSTOM_PROJECT != 'true' ]; then+ if [ $IS_MAIN_REPO == 'true' ]; thenbuildPath="manager/build/install/manager"commitSha=$(git rev-parse HEAD)commitShaShort=$(git rev-parse --short HEAD)@@ -487,12 +508,12 @@ jobs:FIRST_MANAGER_TAG: ${{ steps.ci-cd-output.outputs.firstDockerTag }}MANAGER_TAGS: ${{ steps.ci-cd-output.outputs.dockerTags }}DEPLOYMENTS: ${{ steps.deployments.outputs.value }}- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}TEST_UI_CMD: ${{ steps.test-ui-command.outputs.value }}- name: Define maven publish commandid: maven-publish-command- if: ${{ steps.ci-cd-output.outputs.mavenTag != '' || (steps.is_main_repo.outputs.value && github.ref_type != 'tag' && github.event_name != 'pull_request') }}+ if: ${{ steps.ci-cd-output.outputs.mavenTag != '' || (steps.is_main_repo.outputs.value == 'true' && github.ref_type != 'tag' && github.event_name != 'pull_request') }}shell: bashrun: |command="./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -PsigningKey=$MAVEN_SIGNING_KEY -PsigningPassword=$MAVEN_SIGNING_PASSWORD -PpublishUsername=$MAVEN_USERNAME -PpublishPassword=$MAVEN_PASSWORD"@@ -595,7 +616,6 @@ jobs:echo "************************************************************"echo 'Trigger event: ${{ github.event_name }}'echo 'Is main repo: ${{ steps.is_main_repo.outputs.value == 'true' }}'- echo 'Is custom project repo: ${{ steps.check_custom_project.outputs.files_exists == 'true' }}'echo 'Has deployment dockerfile: ${{ steps.check_deployment_dockerfile.outputs.files_exists == 'true' }}'echo 'Manager commit SHA: ${{ steps.manager-docker-command.outputs.refTag }}'echo 'Deployment commit SHA: ${{ steps.deployment-docker-command.outputs.refTag }}'@@ -625,14 +645,14 @@ jobs:composeProfile='profile/dev-ui.yml'fi- if [ $IS_CUSTOM_PROJECT == 'true' ]; then+ if [ $IS_MAIN_REPO == 'false' ]; thencomposeProfile="openremote/$composeProfile"fi# Pull the imagesdocker compose -f $composeProfile pullenv:- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}TEST_UI_COMMAND: ${{ steps.test-ui-command.outputs.value }}# Use docker layer caching to speed up image building@@ -647,7 +667,7 @@ jobs:run: |composeProfile='profile/dev-testing.yml'- if [ $IS_CUSTOM_PROJECT == 'true' ]; then+ if [ $IS_MAIN_REPO == 'false' ]; thencomposeProfile="openremote/$composeProfile"fi@@ -665,7 +685,7 @@ jobs:# Run the tests${{ steps.test-backend-command.outputs.value }}env:- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}timeout-minutes: 20#continue-on-error: true@@ -733,7 +753,7 @@ jobs:run: |composeProfile='profile/dev-ui.yml'- if [ $IS_CUSTOM_PROJECT == 'true' ]; then+ if [ $IS_MAIN_REPO == 'false' ]; thencomposeProfile="openremote/$composeProfile"fi@@ -743,13 +763,13 @@ jobs:# Run the tests${{ steps.test-ui-command.outputs.value }}env:- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}MANAGER_TAG: ${{ steps.manager-docker-command.outputs.refTag }}timeout-minutes: 20continue-on-error: true- name: Run npm publish command- if: ${{ steps.check_custom_project.outputs.files_exists != 'true' && github.event_name != 'pull_request' }}+ if: ${{ steps.is_main_repo.outputs.value == 'true' && github.event_name != 'pull_request' }}run: |VERSION=$NPM_TAGif [ "$VERSION" == "" ]; then@@ -806,7 +826,7 @@ jobs:deployments = deployments.split(";")managerRef = os.getenv("MANAGER_REF")deploymentRef = os.getenv("DEPLOYMENT_REF")- isCustomProject = os.getenv("IS_CUSTOM_PROJECT")+ isMainRepo = os.getenv("IS_MAIN_REPO")inputsAndSecrets = json.loads(os.getenv("INPUTS_AND_SECRETS"))ipv4 = os.getenv("IPV4")ipv6 = os.getenv("IPV6")@@ -816,7 +836,7 @@ jobs:# Determine deploy script to usedeployScript = ".ci_cd/deploy.sh"- if not os.path.exists(deployScript) and isCustomProject == 'true':+ if not os.path.exists(deployScript) and isMainRepo == 'false':deployScript = "openremote/.ci_cd/deploy.sh"if not os.path.exists(deployScript):@@ -915,7 +935,7 @@ jobs:os.system("echo 'One or more deployments failed'")sys.exit(1)env:- IS_CUSTOM_PROJECT: ${{ steps.check_custom_project.outputs.files_exists }}+ IS_MAIN_REPO: ${{ steps.is_main_repo.outputs.value }}DEPLOYMENTS: ${{ steps.deployments.outputs.value }}MANAGER_DOCKER_BUILD_PATH: ${{ steps.manager-docker-command.outputs.buildPath }}DEPLOYMENT_DOCKER_BUILD_PATH: ${{ steps.deployment-docker-command.outputs.buildPath }}