From 39e6ba767d14d43894f60537a6e54a5d559997d0 Mon Sep 17 00:00:00 2001 From: Ivan Willig Date: Mon, 8 Sep 2025 16:00:12 -0400 Subject: [PATCH 1/2] Add support for local development act --- .actrc | 3 +++ Dockerfile | 4 ++-- entrypoint.sh | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .actrc diff --git a/.actrc b/.actrc new file mode 100644 index 0000000..69c5811 --- /dev/null +++ b/.actrc @@ -0,0 +1,3 @@ +# Act configuration file +# Use smaller runners for faster testing +-P ubuntu-latest=catthehacker/ubuntu:act-latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2388cdb..958be7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM babashka/babashka:1.3.191-alpine -# Install git (needed for git log command in entrypoint) -RUN apk add --no-cache git +# Install git, bash, and openjdk (needed for babashka dependencies) +RUN apk add --no-cache git bash openjdk21-jre # Set working directory WORKDIR /action diff --git a/entrypoint.sh b/entrypoint.sh index 595b792..7f9bbc8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,9 +25,19 @@ if [ -n "$COMMIT_MESSAGE" ]; then echo "Checking provided commit message: $COMMIT_MESSAGE" else # Get the last commit message if none provided - git log -1 --pretty=%B > "$COMMIT_FILE" - COMMIT_MESSAGE=$(cat "$COMMIT_FILE") - echo "Checking last commit message: $COMMIT_MESSAGE" + # Change to workspace directory if it exists (for GitHub Actions) + if [ -d "/github/workspace" ]; then + cd /github/workspace + fi + + if git rev-parse --git-dir > /dev/null 2>&1; then + git log -1 --pretty=%B > "$COMMIT_FILE" + COMMIT_MESSAGE=$(cat "$COMMIT_FILE") + echo "Checking last commit message: $COMMIT_MESSAGE" + else + echo "Error: No git repository found and no commit message provided" + exit 1 + fi fi # Prepare arguments @@ -129,4 +139,4 @@ if [ "$FAIL_ON_ERROR" = "false" ]; then exit 0 else exit $EXIT_CODE -fi \ No newline at end of file +fi From 0977a464b2f2da17fce57eb124193f5d9f99a857 Mon Sep 17 00:00:00 2001 From: Ivan Willig Date: Mon, 8 Sep 2025 16:09:55 -0400 Subject: [PATCH 2/2] Tweak the git entrypoint.sh file --- entrypoint.sh | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7f9bbc8..878bd3e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -25,17 +25,34 @@ if [ -n "$COMMIT_MESSAGE" ]; then echo "Checking provided commit message: $COMMIT_MESSAGE" else # Get the last commit message if none provided - # Change to workspace directory if it exists (for GitHub Actions) - if [ -d "/github/workspace" ]; then - cd /github/workspace - fi - - if git rev-parse --git-dir > /dev/null 2>&1; then - git log -1 --pretty=%B > "$COMMIT_FILE" - COMMIT_MESSAGE=$(cat "$COMMIT_FILE") - echo "Checking last commit message: $COMMIT_MESSAGE" - else + # Try different possible workspace locations for GitHub Actions + WORKSPACE_DIRS=( + "/github/workspace" + "$GITHUB_WORKSPACE" + "$(pwd)" + ) + + GIT_DIR_FOUND=false + for workspace_dir in "${WORKSPACE_DIRS[@]}"; do + if [ -n "$workspace_dir" ] && [ -d "$workspace_dir" ]; then + echo "Checking for git repository in: $workspace_dir" + cd "$workspace_dir" + if git rev-parse --git-dir > /dev/null 2>&1; then + git log -1 --pretty=%B > "$COMMIT_FILE" + COMMIT_MESSAGE=$(cat "$COMMIT_FILE") + echo "Checking last commit message: $COMMIT_MESSAGE" + GIT_DIR_FOUND=true + break + fi + fi + done + + if [ "$GIT_DIR_FOUND" = false ]; then echo "Error: No git repository found and no commit message provided" + echo "Tried directories: ${WORKSPACE_DIRS[*]}" + echo "Current working directory: $(pwd)" + echo "Directory listing:" + ls -la exit 1 fi fi