Skip to content

feat: add support for running the action inside container#71

Merged
ekampf merged 10 commits intomainfrom
feature/lr/support_for_running_inside_docker
Feb 25, 2026
Merged

feat: add support for running the action inside container#71
ekampf merged 10 commits intomainfrom
feature/lr/support_for_running_inside_docker

Conversation

@liorr
Copy link
Contributor

@liorr liorr commented Feb 25, 2026

Summary

  • Add test-linux-docker job to CI workflow to test the action inside a Docker container
  • Add test-linux-docker job to integration tests workflow for the published action
  • Uses ubuntu:24.04 container with --privileged mode to support systemd

Test plan

  • Verify test-linux-docker job passes in CI workflow
  • After merge, verify integration test Docker job passes

🤖 Generated with Claude Code

liorr and others added 3 commits February 24, 2026 21:07
Add a test-linux-docker job to both .github/workflows/ci.yaml and .github/workflows/integration-tests.yaml. The job runs in an ubuntu:24.04 container (--privileged) with a 10-minute timeout, verifies Twingate status and attempts to access a secure resource via curl. In CI it invokes the local action (./) with the SERVICE_KEY secret; in integration-tests it exercises the published action twingate/github-action@main (passing service-key and debug) to validate behavior in a Docker environment.
Use runtime environment variable instead of parse-time context expression
to resolve action path correctly inside Docker containers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add SUDO variable to linux-helpers.sh that's empty when root
- Replace hardcoded sudo with $SUDO in all Linux steps
- Auto-install curl and gnupg if missing in container environments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@liorr liorr changed the title feat: add Docker container tests for GitHub Action feat: add support for running the action inside container Feb 25, 2026
@liorr liorr requested review from Copilot and ekampf February 25, 2026 05:29
TODO: revert to @main after merging PR #71

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for running the Twingate GitHub Action inside Docker containers, specifically testing with ubuntu:24.04 containers. The changes enable the action to work in minimal container environments that run as root and may be missing standard tools like curl and gpg.

Changes:

  • Added SUDO variable to linux-helpers.sh that adapts to whether the action is running as root
  • Updated all script path references from ${{ github.action_path }} to "$GITHUB_ACTION_PATH" for better container compatibility
  • Added prerequisite installation step to install curl and gpg if missing in minimal containers
  • Added test-linux-docker job to both CI and integration test workflows using ubuntu:24.04 containers with --privileged mode

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
scripts/linux-helpers.sh Added SUDO variable that is empty when running as root, otherwise "sudo", enabling the action to work in both container and regular runner environments
action.yml Updated script sourcing to use GITHUB_ACTION_PATH environment variable, replaced all sudo references with $SUDO variable, and added prerequisite installation step for minimal containers
.github/workflows/ci.yaml Added test-linux-docker job to test the action in ubuntu:24.04 container with --privileged mode
.github/workflows/integration-tests.yaml Added test-linux-docker job to test the published action in ubuntu:24.04 container with --privileged mode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

action.yml Outdated
if [ -n "$MISSING_DEPS" ]; then
echo "Installing missing dependencies:$MISSING_DEPS"
apt-get update
apt-get install -y $MISSING_DEPS
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MISSING_DEPS variable should be quoted in the apt-get install command to prevent word splitting issues. While it will likely work in this context, using "$MISSING_DEPS" is a safer practice that prevents potential issues if package names contain special characters.

Suggested change
apt-get install -y $MISSING_DEPS
apt-get install -y "$MISSING_DEPS"

Copilot uses AI. Check for mistakes.
action.yml Outdated
command -v gpg >/dev/null 2>&1 || MISSING_DEPS="$MISSING_DEPS gnupg"

if [ -n "$MISSING_DEPS" ]; then
echo "Installing missing dependencies:$MISSING_DEPS"
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after colon in the echo message. The output will be "Installing missing dependencies:curl gnupg" instead of "Installing missing dependencies: curl gnupg". Add a space after the colon for proper formatting.

Suggested change
echo "Installing missing dependencies:$MISSING_DEPS"
echo "Installing missing dependencies: $MISSING_DEPS"

Copilot uses AI. Check for mistakes.
liorr and others added 3 commits February 24, 2026 21:35
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add "Print client logs" step to test-linux-docker jobs for debugging
- Add SUDO logic to prerequisites step for non-root environments
- Fix spacing in echo message

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When journalctl isn't available, Twingate logs to this file instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +52
if [ -n "$MISSING_DEPS" ]; then
# Use sudo if not running as root and sudo is available
SUDO=""
if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
fi

echo "Installing missing dependencies: $MISSING_DEPS"
$SUDO apt-get update
$SUDO apt-get install -y $MISSING_DEPS
fi
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If dependencies are missing and the environment is non-root without sudo installed, this step will attempt apt-get without privileges and fail, but with a confusing error. Add an explicit check for this case (e.g., detect id -u != 0 and no sudo) and fail fast with a clear message (or document that the action requires root/sudo in containers).

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +106
journalctl -u twingate
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In container environments journalctl may exist but still exit non-zero (e.g., no systemd/journald). Because run steps use bash -e, a non-zero journalctl here will fail the job even though this is a best-effort log dump. Consider appending || true (and --no-pager) to the journalctl/cat commands to ensure the step never fails.

Suggested change
journalctl -u twingate
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log
journalctl -u twingate --no-pager || true
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log || true

Copilot uses AI. Check for mistakes.
env:
TEST_URL: http://business.prod.beamreachinc.int/
run: |
curl -v $TEST_URL
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Docker integration test uses curl -v without --fail, so HTTP 4xx/5xx responses won't fail the step. Add --fail (as used in the existing test-linux job) to ensure the job actually validates access to the protected resource.

Suggested change
curl -v $TEST_URL
curl -v --fail $TEST_URL

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +82
journalctl -u twingate
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to CI, journalctl may be present in the container but still fail if systemd/journald isn't running. With bash -e, that would fail the whole job even though this is an if: always() diagnostics step. Make the journalctl/cat calls non-fatal (e.g., ... || true) so log collection never causes a failure.

Suggested change
journalctl -u twingate
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log
journalctl -u twingate || true
elif [ -f /var/log/twingated.log ]; then
cat /var/log/twingated.log || true

Copilot uses AI. Check for mistakes.
ekampf and others added 3 commits February 25, 2026 09:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ekampf ekampf merged commit 06732f4 into main Feb 25, 2026
17 of 19 checks passed
@ekampf ekampf deleted the feature/lr/support_for_running_inside_docker branch February 25, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants