Skip to content

Commit 4f9615e

Browse files
committed
add user input to not create downloaded files with root owner
1 parent f13a603 commit 4f9615e

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM crowdin/cli:4.14.1
22

3-
RUN apk --no-cache add curl git git-lfs jq gnupg;
3+
RUN apk --no-cache add curl git git-lfs jq gnupg su-exec;
44

55
COPY . .
66
COPY entrypoint.sh /entrypoint.sh

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ By default, the action will look for the `crowdin.yml` file in the root of the r
168168

169169
### Global options
170170

171-
| Option | Description | Example value |
172-
|------------------------|--------------------------------------------------------------------------------------------|----------------------------|
173-
| `crowdin_branch_name` | Option to upload or download files to the specified version branch in your Crowdin project | `main` |
174-
| `config` | Option to specify a path to the configuration file (without `/` at the beginning) | `path/to/your/crowdin.yml` |
175-
| `dryrun_action` | Defines whether to run the action in the dry-run mode | `false` (default) |
171+
| Option | Description | Example value |
172+
|------------------------|---------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
173+
| `crowdin_branch_name` | Option to upload or download files to the specified version branch in your Crowdin project | `main` |
174+
| `config` | Option to specify a path to the configuration file (without `/` at the beginning) | `path/to/your/crowdin.yml` |
175+
| `dryrun_action` | Defines whether to run the action in the dry-run mode | `false` (default) |
176+
| `user` | Run the action as specific user, accepts `uid:gid` or `auto` to detect from workspace ownership. Leave empty to run as root (default) | `auto` |
176177

177178
### GitHub (Enterprise) configuration
178179

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ inputs:
134134
description: 'Option to preview the list of managed files'
135135
default: 'false'
136136
required: false
137+
user:
138+
description: 'Run the action as this user (uid:gid format, e.g. "1001:1001"). Use "auto" to detect from workspace ownership. Leave empty to run as root (default).'
139+
required: false
140+
default: ''
137141

138142
# GitHub (Enterprise) configuration
139143
github_base_url:

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
#!/bin/sh
22

3+
# Re-execute as the specified user if running as root and INPUT_USER is set
4+
if [ -n "$INPUT_USER" ] && [ "$(id -u)" = "0" ]; then
5+
TARGET_USER="$INPUT_USER"
6+
if [ "$INPUT_USER" = "auto" ]; then
7+
TARGET_USER=$(stat -c '%u:%g' "${GITHUB_WORKSPACE}/.git")
8+
fi
9+
exec su-exec "$TARGET_USER" "$0" "$@"
10+
fi
11+
312
# Default values for action outputs
413
echo "pull_request_url=" >> $GITHUB_OUTPUT
514
echo "pull_request_number=" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)