Skip to content

Commit 3d33ebb

Browse files
committed
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.
1 parent 43cab59 commit 3d33ebb

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/actions/devcontainer_run_command/action.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ runs:
178178
- name: Run command in DevContainer
179179
shell: bash
180180
run: |
181+
# Write command to a temporary script file with lowercase name
182+
SCRIPT_FILE=$(mktemp)
183+
mv "${SCRIPT_FILE}" "${SCRIPT_FILE,,}"
184+
SCRIPT_FILE="${SCRIPT_FILE,,}"
185+
cat << 'EOF' > "${SCRIPT_FILE}"
186+
${{ inputs.COMMAND }}
187+
EOF
188+
chmod +x "${SCRIPT_FILE}"
189+
181190
docker run --rm --mount \
182191
"type=bind,src=${{ github.workspace }},dst=/workspaces/tre" \
183192
-v /var/run/docker.sock:/var/run/docker.sock \
@@ -246,4 +255,7 @@ runs:
246255
-e TF_VAR_app_gateway_sku=${{ inputs.APP_GATEWAY_SKU }} \
247256
-e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \
248257
'${{ inputs.CI_CACHE_ACR_NAME }}${{ env.ACR_DOMAIN_SUFFIX }}/tredev:${{ inputs.DEVCONTAINER_TAG }}' \
249-
bash -c "${{ inputs.COMMAND }}"
258+
bash -c "./command.sh"
259+
260+
# Clean up temporary script file
261+
rm "${SCRIPT_FILE}"

.github/workflows/deploy_tre_reusable.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ jobs:
424424
uses: ./.github/actions/devcontainer_run_command
425425
with:
426426
# Although porter publish will build automatically, our makefile build target includes logic that should run
427-
COMMAND: >-
427+
COMMAND: |
428428
for i in {1..3}; do make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }}
429429
&& ec=0 && break || ec=\$? && sleep 30; done; (exit \$ec)
430430
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
@@ -470,7 +470,7 @@ jobs:
470470
uses: ./.github/actions/devcontainer_run_command
471471
with:
472472
# Although porter publish will build automatically, our makefile build target includes logic that should run
473-
COMMAND: >-
473+
COMMAND: |
474474
for i in {1..3}; do make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }}
475475
&& ec=0 && break || ec=\$? && sleep 30; done; (exit \$ec)
476476
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
@@ -514,7 +514,7 @@ jobs:
514514
- name: Register bundle
515515
uses: ./.github/actions/devcontainer_run_command
516516
with:
517-
COMMAND: >-
517+
COMMAND: |
518518
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
519519
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
520520
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
@@ -574,7 +574,7 @@ jobs:
574574
- name: Register bundle
575575
uses: ./.github/actions/devcontainer_run_command
576576
with:
577-
COMMAND: >-
577+
COMMAND: |
578578
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
579579
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
580580
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
@@ -623,7 +623,7 @@ jobs:
623623
- name: Register bundle
624624
uses: ./.github/actions/devcontainer_run_command
625625
with:
626-
COMMAND: >-
626+
COMMAND: |
627627
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
628628
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
629629
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}

0 commit comments

Comments
 (0)