Unable to write multi-line command
I was trying to write a command to pull docker image onto a single instance and run the container, but it would always failed. I tried both | and < for starting the multi-line and also both with and without \ at the end of the line as well. None of it works.
- name: Deploy to sandbox
uses: oracle-actions/[email protected]
if: ${{ vars.SANDBOX_IN_USE == 'false' }}
env:
OCI_CLI_USER: ${{ secrets.OCI_USER_OCID }}
OCI_CLI_TENANCY: ${{ secrets.OCI_TENANCY_OCID }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_REGION }}
REPO_IMAGE_NAME: ${{ env.REPO_IMAGE_NAME }}:sandbox
with:
command: |
instance-agent command create
--compartment-id ${{ secrets.OCI_COMPARTMENT_OCID }}
--target "{
\"instanceId\":\"${{ secrets.OCI_SANDBOX_INSTANCE_OCID }}\"
}"
--content "{
\"source\":{
\"sourceType\":\"TEXT\",
\"text\":\"
echo '${{ secrets.OCI_TOKEN }}' | docker login ${{ env.OCI_CONTAINER_REGISTRY }} -u ${{ secrets.OCI_REGISTRY_USERNAME }} --password-stdin &&
docker pull ${{ env.REPO_IMAGE_NAME }} &&
docker stop ${{ vars.CONTAINER_NAME }} || true &&
docker rm ${{ vars.CONTAINER_NAME }} || true &&
docker run -d -p 80:80 --name ${{ vars.CONTAINER_NAME }} ${{ env.REPO_IMAGE_NAME }}\"
},
\"output\":{
\"outputType\":\"TEXT\"
}
}"
--timeout-in-seconds 3600
--display-name ${{ github.sha }}-deployment
silent: false
Does it work as a single line?
Yep, it works as a single line, though I wish there's a support for multi-line to help keep readability.
Also, I don't think this is the right place, but I do have a question about RunCommands on compute instance. Please let me know where is a good place to reach out to. Basically, the OCI_TOKEN echoed into docker stdin is logged as command content and I'd like to find a way to get around that as I do not want the token to be visible every time it tries to deploy new docker.
Yep, it works as a single line, though I wish there's a support for multi-line to help keep readability.
Patches welcome. :) I'll add it to the todo list, though.