Skip to content

Docker Images for Nektos/act to run your GH-Workflows locally

License

Notifications You must be signed in to change notification settings

mauwii/act-docker-images

Repository files navigation

🐳 Docker images for nektos/act

Docker Pulls Docker Image Size Docker Stars Github stars Github forks Github issues Github last-commit

ci workflow badge MegaLinter Docker-Hub description workflow badge Mergify badge License badge

What

The containers in this repository are made to be used with nektos/act, which is a very handy tool to execute, test and debug github workflows locally.

If you don't know it yet, I highly recommend to check it out 🤓

Why

Since I had trouble with other images when executing azure related tools, I decided to create my own container which is heavily inspired by the images of catthehacker and the official runner images.

How to use

These Docker images are intended to be used with nektos/act. Setup guides can be found here.

Add these lines in ~/.actrc to use this image with act:

-P ubuntu-latest=mauwii/ubuntu-act:latest
-P ubuntu-22.04=mauwii/ubuntu-act:22.04
-P ubuntu-20.04=mauwii/ubuntu-act:20.04

For further information about nektos/act and how to use it, take a 👀 at the nektos documentation📖

How to run act on apple silicon 💻

  • Install act via brew🍺

    brew install act

    [!IMPORTANT]
    Use act --version to make sure you have at least act version 0.2.51, which came with support for node20

  • set an alias to always pass the GITHUB_TOKEN (requires github-cli (brew install gh))

    if command -v act >/dev/null 2>&1; then
        alias act='act -s GITHUB_TOKEN="$(gh auth token)"'
    elif gh extension list | grep -q "nektos/gh-act"; then
        alias act='gh act -s GITHUB_TOKEN="$(gh auth token)"'
    fi
  • 🐳 Docker-Desktop settings:

    • Docker Engine (~/.docker/daemon.json):

      {
        "builder": {
          "gc": {
            "defaultKeepStorage": "20GB",
            "enabled": true
          }
        },
        "experimental": true,
        "features": {
          "buildkit": true
        }
      }
    • Features in Development:

      • ❌ containerd
      • ❌ wasm
      • ✅ rosetta
      • ✅ builds view
    • Advanced:

      • ❌ system
      • ✅ user
      • ✅ Allow the default Docker socket to be used
      • ❌ Allow privileged port mapping
      • ✅ Automatically check configuration
  • ~/.actrc:

    --container-architecture linux/arm64
    --rm=true
    --reuse=false
    -P ubuntu-latest=mauwii/ubuntu-act:latest
    -P ubuntu-22.04=mauwii/ubuntu-act:22.04
    -P ubuntu-20.04=mauwii/ubuntu-act:20.04

docker-bake file

As always, there are different options to build the images locally. I added docker-bake.hcl which helps with orchestrating builds but needs buildx to be available on the host (it comes out of the box with docker desktop).

Warning

Bake Files are still considered experimental, and your results may be totally different depending on your local docker configuration.

  • using the local tag:

    docker buildx bake \
        --set "*.platform=linux/$(uname -m)"
  • using the current branch as a tag name and set better labels, without pushing the cache to the registry:

    GITHUB_SHA="$(git rev-parse HEAD)" \
    REF_NAME="$(git rev-parse --abbrev-ref HEAD)" \
    docker buildx bake \
        --set="*.cache-to=" \
        --set="*.platform=linux/$(uname -m)"

    When you do this from the main branch and already use the latest image, it will be replaced with the one you just built.

mega-linter

To execute the mega-linter locally without the needs to install it, there are different options:

  • you can use act (I assume you run act the way I just explained):

    act -W .github/workflows/mega-linter.yml

    This has the advantage that megalinter executes with the same settings as the workflow itself, while not providing fixed versions if errors where found.

  • or you could use npx:

    npx mega-linter-runner \
        --flavor terraform \
        --remove-container

Pre-Commit-Hook

I integrated a pre-commit hook to run mega-linter. There are different ways to install pre-commit on your system. I used brew since I am working on MacOS (brew install pre-commit). Another easy way would be via pipx.

After successfully installing pre-commit on your system, you need to run pre-commit install in the repository root if you want to enable the pre-commit hooks on your system as well.

About

Docker Images for Nektos/act to run your GH-Workflows locally

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •