File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Test
2+ on :
3+ push :
4+ branches :
5+ - main
6+ pull_request :
7+ jobs :
8+ test-build-args :
9+ name : Test
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v3
13+ - name : build the container and run it
14+ id : run
15+ uses : ./
16+ with :
17+ repository : ${{ github.repository }}
18+ ref : ${{ github.sha }}
19+ dockerfile : tests/Dockerfile.test-build-args
20+ build-args : |
21+ ARG_1:hello
22+ ARG_2:foo
23+ ARG_3:world
24+ - name : check the output
25+ env :
26+ OUTPUTS : ${{steps.run.outputs.outputs }}
27+ ARG_1 : ${{ fromJSON(steps.run.outputs.outputs).arg-1 }}
28+ ARG_2 : ${{ fromJSON(steps.run.outputs.outputs).arg-2 }}
29+ ARG_3 : ${{ fromJSON(steps.run.outputs.outputs).arg-3 }}
30+ run : |
31+ echo ${OUTPUTS}
32+
33+ if [[ "$ARG_1" != "hello" ]]; then
34+ echo "ARG_1 is not hello"
35+ exit 1
36+ fi
37+
38+ if [[ "$ARG_2" != "foo" ]]; then
39+ echo "ARG_2 is not foo"
40+ exit 1
41+ fi
42+
43+ if [[ "$ARG_3" != "world" ]]; then
44+ echo "ARG_3 is not world"
45+ exit 1
46+ fi
47+
48+ echo "all good"
Original file line number Diff line number Diff line change 1+ # a simple container that takes 3 args and generate a shell script that prints them
2+ FROM alpine:3.12.0
3+
4+ ARG ARG_1=default_1
5+ ARG ARG_2=default_2
6+ ARG ARG_3=default_3
7+
8+ RUN echo "#!/bin/sh" > /script.sh
9+ RUN echo 'GITHUB_FILE_COMMANDS="$(dirname "$GITHUB_OUTPUT")"' >> /script.sh
10+ RUN echo 'OUTPUT="${GITHUB_OUTPUT/"$GITHUB_FILE_COMMANDS"/"/github/file_commands"}"' >> /script.sh
11+ RUN echo "echo \"arg-1=$ARG_1\" | tee -a \$OUTPUT" >> /script.sh
12+ RUN echo "echo \"arg-2=$ARG_2\" | tee -a \$OUTPUT" >> /script.sh
13+ RUN echo "echo \"arg-3=$ARG_3\" | tee -a \$OUTPUT" >> /script.sh
14+
15+ RUN chmod +x /script.sh
16+
17+ ENTRYPOINT ["/script.sh"]
You can’t perform that action at this time.
0 commit comments