action-commit-push icon indicating copy to clipboard operation
action-commit-push copied to clipboard

Add cross-platform support for Windows and macOS runners

Open Copilot opened this issue 7 months ago • 0 comments

This PR implements cross-platform compatibility to resolve the "Container action is only supported on Linux" error when running on Windows runners.

Problem

Previously, this action used runs.using: docker which only works on Linux runners. Users trying to run the action on Windows or macOS runners would get:

Error: Container action is only supported on Linux

Solution

Changed the action from a Docker action to a composite action that uses docker run directly, enabling it to work on any runner with Docker installed.

Key Changes

  • action.yml: Changed from docker to composite action type with proper environment variable mapping
  • run.sh: New cross-platform wrapper script that:
    • Detects the operating system
    • Checks Docker availability with helpful error messages
    • Executes the same Docker image using docker run
    • Passes all environment variables and inputs correctly
    • Automatically pulls the image if not present locally
  • README.md: Updated documentation highlighting cross-platform support and Windows setup requirements

Platform Support

  • Linux runners: Fully supported (existing functionality preserved)
  • Windows runners: Now supported with Docker Desktop/Rancher Desktop
  • macOS runners: Now supported with Docker installed

Usage Example

jobs:
  commit-changes:
    runs-on: windows-latest  # Now works!
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      
      - name: Commit changes
        uses: devops-infra/action-commit-push@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          commit_message: "Cross-platform commit from Windows"

Backward Compatibility

✅ Existing Linux workflows continue to work unchanged - same Docker image, same environment, same behavior.

Implementation Details

The solution maintains the exact same execution environment by:

  • Using the identical Docker image (devopsinfra/action-commit-push:v0.10.0)
  • Preserving all environment variables and volume mounts
  • Keeping the same working directory (/github/workspace)
  • Running the same entrypoint.sh script inside the container

The only difference is how the Docker container is invoked:

  • Before: GitHub Actions handles Docker execution (Linux only)
  • After: Wrapper script handles Docker execution (cross-platform)

Fixes #103.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.launchpad.net
    • Triggering command: /usr/bin/python3 /usr/bin/add-apt-repository ppa:git-core/ppa (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Jul 17 '25 13:07 Copilot