From 3d33ebbbca31ff8748aaafe2c48a612751df3001 Mon Sep 17 00:00:00 2001 From: Guy Bertental Date: Thu, 12 Dec 2024 07:44:22 +0000 Subject: [PATCH 1/3] Refactor DevContainer command execution to use a temporary script file - Updated the action to create a temporary script file for the command execution, ensuring the script name is in lowercase. - Changed the command execution from directly passing the command to using the generated script file. - Cleaned up the temporary script file after execution. - Updated workflow files to use a multiline string for the COMMAND input, improving readability. This change enhances the handling of commands in the DevContainer action and maintains a cleaner environment post-execution. --- .../actions/devcontainer_run_command/action.yml | 14 +++++++++++++- .github/workflows/deploy_tre_reusable.yml | 10 +++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/actions/devcontainer_run_command/action.yml b/.github/actions/devcontainer_run_command/action.yml index 55157e1716..21ca45754f 100644 --- a/.github/actions/devcontainer_run_command/action.yml +++ b/.github/actions/devcontainer_run_command/action.yml @@ -178,6 +178,15 @@ runs: - name: Run command in DevContainer shell: bash run: | + # Write command to a temporary script file with lowercase name + SCRIPT_FILE=$(mktemp) + mv "${SCRIPT_FILE}" "${SCRIPT_FILE,,}" + SCRIPT_FILE="${SCRIPT_FILE,,}" + cat << 'EOF' > "${SCRIPT_FILE}" + ${{ inputs.COMMAND }} + EOF + chmod +x "${SCRIPT_FILE}" + docker run --rm --mount \ "type=bind,src=${{ github.workspace }},dst=/workspaces/tre" \ -v /var/run/docker.sock:/var/run/docker.sock \ @@ -246,4 +255,7 @@ runs: -e TF_VAR_app_gateway_sku=${{ inputs.APP_GATEWAY_SKU }} \ -e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \ '${{ inputs.CI_CACHE_ACR_NAME }}${{ env.ACR_DOMAIN_SUFFIX }}/tredev:${{ inputs.DEVCONTAINER_TAG }}' \ - bash -c "${{ inputs.COMMAND }}" + bash -c "./command.sh" + + # Clean up temporary script file + rm "${SCRIPT_FILE}" diff --git a/.github/workflows/deploy_tre_reusable.yml b/.github/workflows/deploy_tre_reusable.yml index e775bed80b..caa0037edd 100644 --- a/.github/workflows/deploy_tre_reusable.yml +++ b/.github/workflows/deploy_tre_reusable.yml @@ -424,7 +424,7 @@ jobs: uses: ./.github/actions/devcontainer_run_command with: # Although porter publish will build automatically, our makefile build target includes logic that should run - COMMAND: >- + COMMAND: | for i in {1..3}; do make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 30; done; (exit \$ec) DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }} @@ -470,7 +470,7 @@ jobs: uses: ./.github/actions/devcontainer_run_command with: # Although porter publish will build automatically, our makefile build target includes logic that should run - COMMAND: >- + COMMAND: | for i in {1..3}; do make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 30; done; (exit \$ec) DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }} @@ -514,7 +514,7 @@ jobs: - name: Register bundle uses: ./.github/actions/devcontainer_run_command with: - COMMAND: >- + COMMAND: | for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec) DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }} @@ -574,7 +574,7 @@ jobs: - name: Register bundle uses: ./.github/actions/devcontainer_run_command with: - COMMAND: >- + COMMAND: | for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec) DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }} @@ -623,7 +623,7 @@ jobs: - name: Register bundle uses: ./.github/actions/devcontainer_run_command with: - COMMAND: >- + COMMAND: | for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec) DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }} From efb15544bf469d5c3964be0c10079c095a839093 Mon Sep 17 00:00:00 2001 From: Guy Bertental Date: Mon, 16 Dec 2024 17:05:05 +0200 Subject: [PATCH 2/3] remove linebreaks --- .github/actions/devcontainer_run_command/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/actions/devcontainer_run_command/action.yml b/.github/actions/devcontainer_run_command/action.yml index 21ca45754f..4c912a8cf1 100644 --- a/.github/actions/devcontainer_run_command/action.yml +++ b/.github/actions/devcontainer_run_command/action.yml @@ -256,6 +256,4 @@ runs: -e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \ '${{ inputs.CI_CACHE_ACR_NAME }}${{ env.ACR_DOMAIN_SUFFIX }}/tredev:${{ inputs.DEVCONTAINER_TAG }}' \ bash -c "./command.sh" - - # Clean up temporary script file rm "${SCRIPT_FILE}" From ddf1cc03a64f6fbdd9bd899fb2478a4d682696b8 Mon Sep 17 00:00:00 2001 From: Guy Bertental Date: Mon, 16 Dec 2024 17:06:20 +0200 Subject: [PATCH 3/3] fix ident --- .github/actions/devcontainer_run_command/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/devcontainer_run_command/action.yml b/.github/actions/devcontainer_run_command/action.yml index 4c912a8cf1..cf4ce730a6 100644 --- a/.github/actions/devcontainer_run_command/action.yml +++ b/.github/actions/devcontainer_run_command/action.yml @@ -256,4 +256,4 @@ runs: -e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \ '${{ inputs.CI_CACHE_ACR_NAME }}${{ env.ACR_DOMAIN_SUFFIX }}/tredev:${{ inputs.DEVCONTAINER_TAG }}' \ bash -c "./command.sh" - rm "${SCRIPT_FILE}" + rm "${SCRIPT_FILE}"