Skip to content

Commit

Permalink
Add shell input support.
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffano committed Jul 16, 2024
1 parent c223d54 commit b85fa3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
ARG IMAGE=alpine:3.20
ARG SHELL=sh
FROM ${IMAGE}
COPY entrypoint.sh /entrypoint.sh
RUN ls -al
RUN pwd
RUN ls -al /entrypoint.sh
COPY entrypoint-${SHELL}.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Configuration
|-------|------|-------------|----------|---------|---------|
| command | string | Shell command to be executed via a Docker container | Yes | - | `cat /etc/*-release` |
| image | string | Docker image to be used for running the container | No | `alpine:3.20` | `ubuntu:22.04` |
| shell | string | Shell to be used for running the command | No | `sh` | `bash` |
12 changes: 9 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ inputs:
type: string
required: false
default: 'alpine:3.20'
shell:
description: |
Shell to be used for running the command
type: string
required: false
default: 'sh'
runs:
using: 'composite'
steps:
- name: Build Docker image
shell: bash
shell: sh
run: |
docker build -f Dockerfile --build-arg IMAGE=${{ inputs.image }} -t local_image:8.8.8 .
docker build -f Dockerfile --build-arg IMAGE=${{ inputs.image }} --build-arg SHELL=${{ inputs.shell }} -t local_image:8.8.8 .
- name: Run Docker container
shell: bash
shell: sh
run: |
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --name local_container local_image:8.8.8 "${{ inputs.command }}"
File renamed without changes.
8 changes: 8 additions & 0 deletions entrypoint-sh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -o errexit
set -o nounset

COMMAND="${1}"

echo "Executing command: ${COMMAND}"
sh -c "${COMMAND}"

0 comments on commit b85fa3b

Please sign in to comment.