Skip to content

Commit

Permalink
Replace path input with extra_path input due to Dockerfile ENV PATH b…
Browse files Browse the repository at this point in the history
…eing overwritten, so we're opting to explicitly set the PATH in entrypoint script with extra PATH being pre-pended to the original PATH.
  • Loading branch information
cliffano committed Nov 1, 2024
1 parent 9d507e7 commit c824621
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
command: 'echo "$PATH"'
image: ubuntu:22.04
shell: bash
path: '/some/path:/opt/workspace/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
extra_path: '/some/path:/opt/workspace/bin'
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Added
- Add path input configuration
- Add extra_path input configuration

## 1.2.0 - 2024-11-01
### Added
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ ARG IMAGE=alpine:3.20
FROM ${IMAGE}
CMD mkdir -p /opt/workspace/
WORKDIR /opt/workspace/
ARG PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ENV PATH="${PATH}"
ARG SHELL=sh
COPY entrypoint-${SHELL}.sh /opt/entrypoint.sh
ENTRYPOINT ["/opt/entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ 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` |
| path | string | Shell to be used for running the command | No | `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` | `/some/path:/opt/workspace/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` |
| extra_path | string | Extra PATH environment variable to be added to original PATH during shell command execution | No | `` | `/some/path:/opt/workspace/bin` |
| shell | string | PATH environment variable to be set during shell command execution | No | `sh` | `sh`, `bash` |
| env_file | string | Path to env file containing environment variables made available during shell command execution | No | `` | `/tmp/.env` |
12 changes: 6 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ inputs:
type: string
required: false
default: 'sh'
path:
extra_path:
description: |
PATH environment variable to be set during shell command execution
Extra PATH environment variable to be added to original PATH during shell command execution
type: string
required: false
default: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
default: ''
env_file:
description: |
Path to env file containing environment variables made available during shell command execution
Path to env file containing environment variables made available during shell command execution
type: string
required: false
default: ''
Expand All @@ -42,7 +42,7 @@ runs:
- name: Build Docker image on the the GitHub Action directory
shell: sh
run: |
cd $GITHUB_ACTION_PATH && docker build -f Dockerfile --build-arg IMAGE=${{ inputs.image }} --build-arg PATH=${{ inputs.path }} --build-arg SHELL=${{ inputs.shell }} -t local_image:8.8.8 .
cd $GITHUB_ACTION_PATH && docker build -f Dockerfile --build-arg IMAGE=${{ inputs.image }} --build-arg SHELL=${{ inputs.shell }} -t local_image:8.8.8 .
- name: Run Docker container on the GitHub Workspace directory
if: inputs.env_file == ''
shell: sh
Expand All @@ -52,4 +52,4 @@ runs:
if: inputs.env_file != ''
shell: sh
run: |
cd $GITHUB_WORKSPACE && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v .:/opt/workspace/ --env-file "${{ inputs.env_file }}" --name local_container local_image:8.8.8 "${{ inputs.command }}"
cd $GITHUB_WORKSPACE && docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v .:/opt/workspace/ --env-file "${{ inputs.env_file }}" --name local_container local_image:8.8.8 "${{ inputs.command }}" "${{ inputs.extra_path }}"
3 changes: 3 additions & 0 deletions entrypoint-bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set -o errexit
set -o nounset

COMMAND="${1}"
EXTRA_PATH="${2}"

export PATH="${EXTRA_PATH}:${PATH}"

echo "PATH: ${PATH}"

Expand Down
3 changes: 3 additions & 0 deletions entrypoint-sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ set -o errexit
set -o nounset

COMMAND="${1}"
EXTRA_PATH="${2}"

export PATH="${EXTRA_PATH}:${PATH}"

echo "PATH: ${PATH}"

Expand Down

0 comments on commit c824621

Please sign in to comment.