Skip to content

Commit

Permalink
support multiple lines in devcontainer action (#4192)
Browse files Browse the repository at this point in the history
Updated workflow files to use a multiline string for the COMMAND input, improving readability.
  • Loading branch information
guybartal authored Feb 13, 2025
1 parent 72e98c3 commit 3a5ecb9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
15 changes: 14 additions & 1 deletion .github/actions/devcontainer_run_command/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,19 @@ runs:
- name: Run command in DevContainer
shell: bash
run: |
# Write command to a command.sh script file
cat <<EOF >> ./command.sh
#!/bin/bash
set -x
${{ inputs.COMMAND }}
EOF
chmod +x ./command.sh
docker run --rm --mount \
"type=bind,src=${{ github.workspace }},dst=/workspaces/tre" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "./command.sh:/workspaces/tre/command.sh" \
--workdir /workspaces/tre \
--user vscode \
-e TF_INPUT="0" \
Expand Down Expand Up @@ -246,4 +256,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 -x "./command.sh"
# Clean up temporary script file
rm ./command.sh
55 changes: 40 additions & 15 deletions .github/workflows/deploy_tre_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,14 @@ jobs:
uses: ./.github/actions/devcontainer_run_command
with:
# Although porter publish will build automatically, our makefile build target includes logic that should run
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)
COMMAND: |
# Loop to retry the make command up to 3 times
for i in {1..3}; do
make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 30;
done;
# Exit with the last status code
(exit \$ec)
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_ENVIRONMENT: ${{ vars.AZURE_ENVIRONMENT }}
Expand Down Expand Up @@ -470,9 +475,14 @@ jobs:
uses: ./.github/actions/devcontainer_run_command
with:
# Although porter publish will build automatically, our makefile build target includes logic that should run
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)
COMMAND: |
# Loop to retry the make command up to 3 times
for i in {1..3}; do
make bundle-build bundle-publish DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 30;
done
# Exit with the last status code
(exit \$ec)
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_ENVIRONMENT: ${{ vars.AZURE_ENVIRONMENT }}
Expand Down Expand Up @@ -514,9 +524,14 @@ jobs:
- name: Register bundle
uses: ./.github/actions/devcontainer_run_command
with:
COMMAND: >-
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
COMMAND: |
# Loop to retry the make command up to 3 times
for i in {1..3}; do
make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10;
done
# Exit with the last status code
(exit \$ec)
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
CI_CACHE_ACR_NAME: ${{ secrets.CI_CACHE_ACR_NAME}}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand Down Expand Up @@ -574,9 +589,14 @@ jobs:
- name: Register bundle
uses: ./.github/actions/devcontainer_run_command
with:
COMMAND: >-
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
COMMAND: |
# Loop to retry the make command up to 3 times
for i in {1..3}; do
make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10;
done;
# Exit with the last status code
(exit \$ec)
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
CI_CACHE_ACR_NAME: ${{ secrets.CI_CACHE_ACR_NAME}}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand Down Expand Up @@ -623,9 +643,14 @@ jobs:
- name: Register bundle
uses: ./.github/actions/devcontainer_run_command
with:
COMMAND: >-
for i in {1..3}; do make bundle-register DIR=${{ matrix.BUNDLE_DIR }}
&& ec=0 && break || ec=\$? && sleep 10; done; (exit \$ec)
COMMAND: |
# Loop to retry the make command up to 3 times
for i in {1..3}; do
make bundle-register DIR=${{ matrix.BUNDLE_DIR }} && ec=0 && break || ec=\$? && sleep 10;
done;
# Exit with the last status code
(exit \$ec)
DEVCONTAINER_TAG: ${{ inputs.DEVCONTAINER_TAG }}
CI_CACHE_ACR_NAME: ${{ secrets.CI_CACHE_ACR_NAME}}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
Expand Down

0 comments on commit 3a5ecb9

Please sign in to comment.