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
Publish docker images for all branches as snapshots to private ECR registry (#2091)
Eric Bariaux07711ea667a7
diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.ymlindex 88997ea6f..4ae7fa590 100644--- a/.github/workflows/ci_cd.yml+++ b/.github/workflows/ci_cd.yml@@ -90,6 +90,9 @@ on:SECRETS:required: false+permissions:+ id-token: write+concurrency:group: ${{ github.workflow }}-${{ github.ref }}cancel-in-progress: true@@ -400,7 +403,7 @@ jobs:inputEnv = os.getenv('INPUT_ENVIRONMENT')managerVersion = os.getenv('MANAGER_VERSION')- if eventName == 'workflow_dispatch' and refType != 'tag':+ if eventName == 'workflow_dispatch' and refType != 'tag' and inputEnv and inputEnv.strip():if isMainRepo:tag=inputTagif not inputTag:@@ -447,16 +450,15 @@ jobs:if [ "$(uname -m)" == "aarch64" ]; thenPLATFORM=linux/aarch64- OTHER_PLATFORM=linux/amd64fiif [ -n "$MANAGER_TAGS" ] || [[ "$DEPLOYMENTS" == *"#ref"* ]] || [ -n "$TEST_UI_CMD" ]; thenif [ -n "$MANAGER_TAGS" ]; thencommand="docker build --push --build-arg GIT_COMMIT=$commitSha --platform linux/amd64,linux/aarch64 $MANAGER_TAGS $buildPath && docker build --build-arg GIT_COMMIT=$commitSha --platform ${PLATFORM:-linux/amd64} --load -t openremote/manager:$commitShaShort $buildPath"- echo "pushRequired=true" >> $GITHUB_OUTPUT+ echo "pushToDockerHub=true" >> $GITHUB_OUTPUTecho "managerDockerImage=openremote/manager:$FIRST_MANAGER_TAG" >> $GITHUB_OUTPUTelse- command="docker build --build-arg GIT_COMMIT=$commitSha --platform ${PLATFORM:-linux/amd64} --load -t openremote/manager:$commitShaShort $buildPath && docker build --build-arg GIT_COMMIT=$commitSha --platform ${OTHER_PLATFORM:-linux/aarch64} -t openremote/manager:$commitShaShort $buildPath"+ command="docker build --push --build-arg GIT_COMMIT=$commitSha --platform linux/amd64,linux/aarch64 -t ${{ secrets.OR_AWS_DEVELOPERS_ACCOUNT_ID }}.dkr.ecr.eu-west-1.amazonaws.com/openremote/manager:SNAPSHOT-$commitShaShort $buildPath && docker build --build-arg GIT_COMMIT=$commitSha --platform ${PLATFORM:-linux/amd64} --load -t openremote/manager:$commitShaShort $buildPath"echo "managerDockerImage=openremote/manager:$commitShaShort" >> $GITHUB_OUTPUTfiecho "value=$command" >> $GITHUB_OUTPUT@@ -523,12 +525,23 @@ jobs:DEPLOYMENT_DOCKER_CMD: ${{ steps.deployment-docker-command.outputs.value }}- name: Login to DockerHub- if: ${{ steps.manager-docker-command.outputs.pushRequired == 'true' }}+ if: ${{ steps.manager-docker-command.outputs.pushToDockerHub == 'true' }}uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3with:username: ${{ steps.inputs-and-secrets.outputs._TEMP_DOCKERHUB_USER }}password: ${{ steps.inputs-and-secrets.outputs._TEMP_DOCKERHUB_PASSWORD }}+ - name: Configure AWS Credentials+ if: ${{ steps.manager-docker-command.outputs.pushToDockerHub != 'true' }}+ uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0+ with:+ aws-region: eu-west-1+ role-to-assume: "arn:aws:iam::${{ secrets.OR_AWS_DEVELOPERS_ACCOUNT_ID }}:role/${{ secrets.OR_GH_AWS_ECR_PUSH_ROLE }}"++ - name: Login to private ECR+ if: ${{ steps.manager-docker-command.outputs.pushToDockerHub != 'true' }}+ uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1+- name: set up QEMUif: ${{ steps.manager-docker-command.outputs.value != '' || steps.deployment-docker-command.outputs.value != '' }}uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3@@ -762,7 +775,7 @@ jobs:path: ui/app/*/app-test-report/**- name: Scan manager docker image- if: steps.manager-docker-command.outputs.pushRequired == 'true'+ if: steps.manager-docker-command.outputs.pushToDockerHub == 'true'uses: anchore/scan-action@2c901ab7378897c01b8efaa2d0c9bf519cc64b9e # v6.2.0id: manager-anchore-scanwith:@@ -773,7 +786,7 @@ jobs:- name: Upload Anchore scan SARIF reportif: |!cancelled() &&- steps.manager-docker-command.outputs.pushRequired == 'true'+ steps.manager-docker-command.outputs.pushToDockerHub == 'true'uses: github/codeql-action/upload-sarif@e488e3c8239c26bf8e6704904a8cb59be658d450 # v3with:sarif_file: ${{ steps.manager-anchore-scan.outputs.sarif }}@@ -781,7 +794,7 @@ jobs:- name: Inspect Anchore scan SARIF reportif: |!cancelled() &&- steps.manager-docker-command.outputs.pushRequired == 'true'+ steps.manager-docker-command.outputs.pushToDockerHub == 'true'run: cat ${{ steps.manager-anchore-scan.outputs.sarif }}- name: Run maven publish command