Skip to content

Commit 5482653

Browse files
authored
refactor(pip-compile-upgrade): run using docker (#104)
1 parent edc050e commit 5482653

File tree

3 files changed

+11
-38
lines changed

3 files changed

+11
-38
lines changed

pip-compile-upgrade/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ FROM ghcr.io/coatl-dev/python-tools:2.7-pip-tools
22

33
LABEL \
44
maintainer="César Román <cesar@coatl.dev>" \
5-
repository="https://github.com/coatl-dev/actions/blob/coatl/pip-compile" \
5+
repository="https://github.com/coatl-dev/actions/blob/coatl/pip-compile-upgrade" \
66
vendor="coatl.dev"
77

88
COPY action.sh /action.sh
99
RUN chmod +x /action.sh
1010

11-
WORKDIR "/github/workspace"
1211
ENTRYPOINT ["/action.sh"]

pip-compile-upgrade/action.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,12 @@ source /etc/profile # Makes python and other executables findable
66

77
function process_file() {
88
local file="$1"
9-
local use_config="$INPUT_USE_CONFIG"
10-
local config_file="$INPUT_CONFIG_FILE"
119
local extra_args="${INPUT_EXTRA_ARGS:-}"
1210

1311
command=$(grep -m 1 "# pip-compile" "$file")
1412
if [ -n "$command" ]; then
15-
if [ "$use_config" == "yes" ]; then
16-
if [ -f "$config_file" ]; then
17-
file_name=$(grep -m 1 -E "# pip-compile.*(pyproject\.toml|setup\.cfg|setup\.py|[^ ]+\.in)" "$file" | sed -E "s/.*(# pip-compile.* (pyproject\.toml|setup\.cfg|setup\.py|[^ ]+\.in)).*/\2/")
18-
upgrade_command="pip-compile --upgrade $extra_args --config $config_file $file_name"
19-
eval "$upgrade_command"
20-
else
21-
exit 1
22-
fi
23-
else
24-
upgrade_command=$(grep -m 1 "# pip-compile" "$file" | sed "s/# pip-compile/pip-compile --upgrade $extra_args/")
25-
eval "$upgrade_command"
26-
fi
13+
upgrade_command=$(grep -m 1 "# pip-compile" "$file" | sed "s/# pip-compile/pip-compile --upgrade $extra_args/")
14+
eval "$upgrade_command"
2715
else
2816
exit 1
2917
fi

pip-compile-upgrade/action.yaml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: coatl-dev-pip-compile
2-
description: Run pip-compile to upgrade your Python 2/3 requirements.
1+
name: coatl-dev-pip-compile-upgrade
2+
description: Run pip-compile to upgrade your Python 2.7 requirements.
33
author: cesarcoatl
44

55
inputs:
@@ -19,23 +19,9 @@ inputs:
1919
default: '.'
2020

2121
runs:
22-
using: composite
23-
steps:
24-
- shell: bash
25-
run: |
26-
docker build \
27-
--build-arg VERSION=${{ inputs.python-version }} \
28-
--file ${{ github.action_path }}/Dockerfile \
29-
--tag coatl-dev-pip-compile-upgrade-action \
30-
${{ github.action_path }}
31-
32-
- shell: bash
33-
run: |
34-
docker run --rm \
35-
--env "INPUT_PATH=${{ inputs.path }}" \
36-
--env "INPUT_USE_CONFIG=${{ inputs.use-config }}" \
37-
--env "INPUT_CONFIG_FILE=${{ inputs.config-file }}" \
38-
--env "INPUT_EXTRA_ARGS=${{ inputs.extra-args }}" \
39-
--env "INPUT_WORKING_DIRECTORY=${{ inputs.working-directory }}" \
40-
--volume ${{ github.workspace }}://github/workspace \
41-
coatl-dev-pip-compile-upgrade-action
22+
using: docker
23+
image: Dockerfile
24+
env:
25+
INPUT_PATH: ${{ inputs.path }}
26+
INPUT_EXTRA_ARGS: ${{ inputs.extra-args }}
27+
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}

0 commit comments

Comments
 (0)