Using the Semicolon (;) Operator Segmenting a chain of commands with the semicolon is the most common practice when you want to run multiple commands in a terminal.
The semicolon (;) operator allows you to execute multiple commands in succession, regardless of whether each previous command succeeds. For example, open a Terminal window (Ctrl+Alt+T in Ubuntu and Linux Mint).
GitHub Actions usage is free for both public repositories and self-hosted runners. For private repositories, each GitHub account receives a certain amount of free minutes and storage, depending on the product used with the account.
To set a custom environment variable, you must define it in the workflow file. The scope of a custom environment variable is limited to the element in which it is defined. You can define environment variables that are scoped for: The entire workflow, by using env at the top level of the workflow file.
You can run multiple commands using a pipe |
on the run
attribute. Check this out:
name: My Workflow
on: [push]
jobs:
runMultipleCommands:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: |
echo "A initial message"
pip install -r requirements.txt
echo "Another message or command"
python myscript.py
bash some-shell-script-file.sh -xe
- run: echo "One last message"
On my tests, running a shell script like ./myscript.sh
returns a ``. But running it like bash myscript.sh -xe
worked like expected.
My workflow file | Results
If you want to run this inside the docker machine, an option could be run some like this on you run
clause:
docker exec -it pseudoName /bin/bash -c "cd myproject; pip install -r requirements.txt;"
Regard to the "create another Docker for another command, which will contain the output of the previous Docker", you could use multistage-builds on your dockerfile. Some like:
## First stage (named "builder")
## Will run your command (using add git as sample) and store the result on "output" file
FROM alpine:latest as builder
RUN apk add git > ./output.log
## Second stage
## Will copy the "output" file from first stage
FROM alpine:latest
COPY --from=builder ./output.log .
RUN cat output.log
# RUN your checks
CMD []
This way the apk add git
result was saved to a file, and this file was copied to the second stage, that can run any check on the results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With