-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from pl-strflt/feat/add-test
feat: add test for build-args
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
test-build-args: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: build the container and run it | ||
id: run | ||
uses: ./ | ||
with: | ||
repository: ${{ github.repository }} | ||
ref: ${{ github.sha }} | ||
dockerfile: tests/Dockerfile.test-build-args | ||
build-args: | | ||
ARG_1:hello | ||
ARG_2:foo | ||
ARG_3:world | ||
- name: check the output | ||
env: | ||
OUTPUTS: ${{steps.run.outputs.outputs }} | ||
ARG_1: ${{ fromJSON(steps.run.outputs.outputs).arg-1 }} | ||
ARG_2: ${{ fromJSON(steps.run.outputs.outputs).arg-2 }} | ||
ARG_3: ${{ fromJSON(steps.run.outputs.outputs).arg-3 }} | ||
run: | | ||
echo ${OUTPUTS} | ||
if [[ "$ARG_1" != "hello" ]]; then | ||
echo "ARG_1 is not hello" | ||
exit 1 | ||
fi | ||
if [[ "$ARG_2" != "foo" ]]; then | ||
echo "ARG_2 is not foo" | ||
exit 1 | ||
fi | ||
if [[ "$ARG_3" != "world" ]]; then | ||
echo "ARG_3 is not world" | ||
exit 1 | ||
fi | ||
echo "all good" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# a simple container that takes 3 args and generate a shell script that prints them | ||
FROM alpine:3.12.0 | ||
|
||
ARG ARG_1=default_1 | ||
ARG ARG_2=default_2 | ||
ARG ARG_3=default_3 | ||
|
||
RUN echo "#!/bin/sh" > /script.sh | ||
RUN echo 'GITHUB_FILE_COMMANDS="$(dirname "$GITHUB_OUTPUT")"' >> /script.sh | ||
RUN echo 'OUTPUT="${GITHUB_OUTPUT/"$GITHUB_FILE_COMMANDS"/"/github/file_commands"}"' >> /script.sh | ||
RUN echo "echo \"arg-1=$ARG_1\" | tee -a \$OUTPUT" >> /script.sh | ||
RUN echo "echo \"arg-2=$ARG_2\" | tee -a \$OUTPUT" >> /script.sh | ||
RUN echo "echo \"arg-3=$ARG_3\" | tee -a \$OUTPUT" >> /script.sh | ||
|
||
RUN chmod +x /script.sh | ||
|
||
ENTRYPOINT ["/script.sh"] |