Compare commits

..

14 commits

Author SHA1 Message Date
efce8b0767 Update action.yml 2025-06-18 10:21:27 +02:00
61452555f6 Update action.yml 2025-06-18 10:16:57 +02:00
Foat
674fa2c329
Merge pull request #8 from Frozen-Tapestry/develop
Escape spaces within args
2025-03-19 20:48:25 +03:00
Foat Akhmadeev
1a5b0ee26d upd releases 2025-03-19 20:45:32 +03:00
Foat Akhmadeev
2ad594c591 escaped spaces update 2025-03-19 20:38:18 +03:00
Foat
a4a415f922
Merge pull request #6 from Frozen-Tapestry/develop
uname hotfix
2025-02-28 17:07:52 +03:00
Foat Akhmadeev
f736377de1 uname hotfix 2025-02-28 17:03:47 +03:00
Foat
09c93ff653
Merge pull request #5 from Frozen-Tapestry/develop
New release with permission fix
2025-02-28 16:42:45 +03:00
Foat
25cafbfcad
Merge pull request #4 from Frozen-Tapestry/fix/clone-err2
Permission fix & readme update
2025-02-28 16:40:07 +03:00
Foat Akhmadeev
1510e5208d readme and release updates 2025-02-28 16:38:44 +03:00
Foat Akhmadeev
8f948270a6 Merge commit 'db55fdf5f3' into fix/clone-err2 2025-02-28 16:27:01 +03:00
Foat
db55fdf5f3
Merge pull request #2 from felipet/prime
The container image is wrong in the documentation
2025-02-28 16:22:51 +03:00
Foat Akhmadeev
7de88c59ce sudo permission fix 2025-02-28 16:18:42 +03:00
Felipe Torres González
0f0c5bd8ea
Update README.md
Fix wrong name of the action image
2025-02-28 09:27:45 +01:00
6 changed files with 86 additions and 35 deletions

3
.github/pull_request_template.md vendored Normal file
View file

@ -0,0 +1,3 @@
### Base branch for this PR
Please target the `develop` branch for this Pull Request.

View file

@ -25,7 +25,11 @@ jobs:
ARG MY_ENV_VAR2 ARG MY_ENV_VAR2
ENV MY_ENV_VAR=$MY_ENV_VAR ENV MY_ENV_VAR=$MY_ENV_VAR
ENV MY_ENV_VAR2=$MY_ENV_VAR2 ENV MY_ENV_VAR2=$MY_ENV_VAR2
CMD ["sh", "-c", "echo Result: $MY_ENV_VAR $MY_ENV_VAR2"]' > Dockerfile ARG EXTRA_ENV_VAR
ARG EXTRA_ENV_VAR2
ENV EXTRA_ENV_VAR=$EXTRA_ENV_VAR
ENV EXTRA_ENV_VAR2=$EXTRA_ENV_VAR2
CMD ["sh", "-c", "echo Result: $MY_ENV_VAR $MY_ENV_VAR2 ~$EXTRA_ENV_VAR~ ~$EXTRA_ENV_VAR2~"]' > Dockerfile
cat Dockerfile cat Dockerfile
- name: Use Build and Push action - name: Use Build and Push action
uses: ./ uses: ./
@ -36,6 +40,7 @@ jobs:
tags: ghcr.io/frozen-tapestry/podman-action-verify:latest tags: ghcr.io/frozen-tapestry/podman-action-verify:latest
dockerfile: Dockerfile dockerfile: Dockerfile
build_args: MY_ENV_VAR=Test MY_ENV_VAR2=Test2 build_args: MY_ENV_VAR=Test MY_ENV_VAR2=Test2
extra_args: --build-arg EXTRA_ENV_VAR="Extra\ env\ 1" --build-arg=EXTRA_ENV_VAR2=Extra\ env\ 2
security: | security: |
--security-opt=seccomp=unconfined --security-opt=seccomp=unconfined
--security-opt=apparmor=unconfined --security-opt=apparmor=unconfined
@ -46,7 +51,7 @@ jobs:
OUTPUT=$(docker run --rm ghcr.io/frozen-tapestry/podman-action-verify:latest) OUTPUT=$(docker run --rm ghcr.io/frozen-tapestry/podman-action-verify:latest)
echo "Container Output: $OUTPUT" echo "Container Output: $OUTPUT"
if [ "$OUTPUT" != "Result: Test Test2" ]; then if [ "$OUTPUT" != "Result: Test Test2 ~\"Extra env 1\"~ ~Extra env 2~" ]; then
echo "Output does not match expected string" echo "Output does not match expected string"
exit 1 exit 1
fi fi

View file

@ -46,13 +46,17 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Use Podman Build and Push Action - name: Use Podman Build and Push Action
uses: frozen-tapestry/podman-build-push-action@v1 uses: Frozen-Tapestry/container-action@v1
with: with:
login_registry: ghcr.io login_registry: ghcr.io
login_username: ${{ secrets.REGISTRY_USERNAME }} login_username: ${{ secrets.REGISTRY_USERNAME }}
login_password: ${{ secrets.REGISTRY_PASSWORD }} login_password: ${{ secrets.REGISTRY_PASSWORD }}
tags: ghcr.io/your-namespace/your-image:latest tags: ghcr.io/your-namespace/your-image:latest
dockerfile: path/to/Dockerfile dockerfile: path/to/Dockerfile
# Use those security flags if using GitHub Action. Keep the defaults, if using Gitea.
security: |
--security-opt=seccomp=unconfined
--security-opt=apparmor=unconfined
push: true push: true
``` ```

View file

@ -2,4 +2,13 @@
### v1.0.0 ### v1.0.0
- Initial release - Initial release
### v1.1.0
- Permission error fix
- Readme updates
### v1.2.0
- Added support for escaped spaces

View file

@ -25,13 +25,13 @@ inputs:
required: false required: false
build_args: build_args:
description: | description: |
Optional build arguments. Space-separated. e.g. Optional build arguments. Space-separated, escape space if used within single arg. e.g.
MY_ENV_VAR=Test MY_ENV_VAR2=Test2 MY_ENV_VAR=Test MY_ENV_VAR2=Test2
required: false required: false
extra_args: extra_args:
description: | description: |
Extra args to be passed to podman. Space-separated. e.g. Extra args to be passed to podman. Space-separated, escape space if used within single arg. e.g.
-e=MY_ENV=Test -e=MY_ENV=Test2 -e=MY_ENV=Test -e=MY_ENV=Test2 -e MY_ENV=Var\ with\ spaces
required: false required: false
dockerfile: dockerfile:
description: Path to the Dockerfile. If set, build step is performed. description: Path to the Dockerfile. If set, build step is performed.
@ -49,7 +49,7 @@ runs:
using: composite using: composite
steps: steps:
- name: Run container steps - name: Run container steps
uses: frozen-tapestry/docker-run-action@v6 uses: https://git.zio.sh/astra/docker-run-action@bc0813212cba1c029615a08be520b15613988af3
with: with:
image: quay.io/podman/stable:latest image: quay.io/podman/stable:latest
mount_ws: true mount_ws: true

View file

@ -13,24 +13,48 @@ PODMAN_USER="podman"
chown $PODMAN_USER:$PODMAN_USER /home/$PODMAN_USER/auth chown $PODMAN_USER:$PODMAN_USER /home/$PODMAN_USER/auth
chown $PODMAN_USER:$PODMAN_USER /home/$PODMAN_USER/.local/share/containers/storage chown $PODMAN_USER:$PODMAN_USER /home/$PODMAN_USER/.local/share/containers/storage
run_cmd() {
local build_cmd=("$@")
cmd=$(printf "%q\t" "${build_cmd[@]}")
echo "Running: $cmd"
su "$PODMAN_USER" -c "$cmd"
}
### LOGIN ### LOGIN
if [[ -n "$REGISTRY" && -n "$USERNAME" && -n "$PASSWORD" ]]; then if [[ -n "$REGISTRY" && -n "$USERNAME" && -n "$PASSWORD" ]]; then
sudo -u $PODMAN_USER podman login \ build_cmd=(podman login
--storage-driver=overlay \ --storage-driver=overlay
--authfile="$REGISTRY_AUTH_FILE" \ --authfile="$REGISTRY_AUTH_FILE"
"$REGISTRY" -u "$USERNAME" -p "$PASSWORD" "$REGISTRY"
--username="$USERNAME"
--password="$PASSWORD"
)
run_cmd "${build_cmd[@]}"
fi fi
# Function that splits on unescaped spaces (but not on escaped ones)
# and outputs each processed token on a new line.
generate_args() { generate_args() {
local input_args="$1" local input_args="$1"
local prefix="$2" local prefix="$2"
local output="" local output=()
local placeholder="__ESCAPED_SPACE__"
if [[ -n "$input_args" ]]; then if [[ -n "$input_args" ]]; then
output="$(echo "$input_args" | tr -s ' ' '\n' | sed "s/[^ ]* */$prefix&/g")" # Replace escaped spaces (\ ) with a unique placeholder.
local temp="${input_args//\\ /$placeholder}"
# Split on spaces (escaped ones are now hidden).
IFS=' ' read -r -a parts <<< "$temp"
for part in "${parts[@]}"; do
# Skip any empty parts.
[[ -z "$part" ]] && continue
# Restore escaped spaces.
part="${part//$placeholder/ }"
output+=("$prefix$part")
done
fi fi
echo "$output" printf "%s\n" "${output[@]}"
} }
### BUILD ### BUILD
@ -42,34 +66,40 @@ if [[ -n "$DOCKERFILE" ]]; then
echo "Main labels: $CREATED $REVISION $SOURCE" echo "Main labels: $CREATED $REVISION $SOURCE"
TAGS=$(generate_args "$ACTION_TAGS" "-t=") TAGS=$(generate_args "$ACTION_TAGS" "-t=")
echo "Tags: $TAGS" echo "Tags: ${TAGS[@]}"
LABELS=$(generate_args "$ACTION_LABELS" "--label=") LABELS=$(generate_args "$ACTION_LABELS" "--label=")
echo "Labels: $LABELS" echo "Labels: ${LABELS[@]}"
BUILD_ARGS=$(generate_args "$ACTION_BUILD_ARGS" "--build-arg=") BUILD_ARGS=$(generate_args "$ACTION_BUILD_ARGS" "--build-arg=")
echo "Build args: $BUILD_ARGS" echo "Build args: ${BUILD_ARGS[@]}"
EXTRA_ARGS=$(generate_args "$ACTION_EXTRA_ARGS" "") EXTRA_ARGS=$(generate_args "$ACTION_EXTRA_ARGS" "")
echo "Extra args: $EXTRA_ARGS" echo "Extra args: ${EXTRA_ARGS[@]}"
sudo -u $PODMAN_USER podman build --platform="linux/amd64" \ build_cmd=(podman build
--storage-driver=overlay \ --platform="linux/amd64"
--authfile="$REGISTRY_AUTH_FILE" \ --storage-driver=overlay
--pull=true \ --authfile="$REGISTRY_AUTH_FILE"
--label image.created="$CREATED" \ --pull=true
--label image.revision="$REVISION" \ --label=image.created="$CREATED"
--label image.source="$SOURCE" \ --label=image.revision="$REVISION"
$TAGS \ --label=image.source="$SOURCE"
$LABELS \ $TAGS
$BUILD_ARGS \ $LABELS
$EXTRA_ARGS \ $BUILD_ARGS
-f "$DOCKERFILE" \ $EXTRA_ARGS
--file="$DOCKERFILE"
. .
)
run_cmd "${build_cmd[@]}"
fi fi
if [[ -n "$PUSH" && "$PUSH" == "true" ]]; then if [[ -n "$PUSH" && "$PUSH" == "true" ]]; then
TAGS=$(generate_args "$ACTION_TAGS" "") TAGS=$(generate_args "$ACTION_TAGS" "")
echo "Tags: $TAGS" echo "Tags: ${TAGS[@]}"
sudo -u $PODMAN_USER podman push \ build_cmd=(podman push
--storage-driver=overlay \ --storage-driver=overlay
--authfile="$REGISTRY_AUTH_FILE" $TAGS --authfile="$REGISTRY_AUTH_FILE"
$TAGS
)
run_cmd "${build_cmd[@]}"
fi fi