Skip to content

Instantly share code, notes, and snippets.

@tobocop2
Last active February 23, 2024 18:57
Show Gist options
  • Save tobocop2/07863ae70b9e5078f573d424b04f3185 to your computer and use it in GitHub Desktop.
Save tobocop2/07863ae70b9e5078f573d424b04f3185 to your computer and use it in GitHub Desktop.
portable act

README

To build the act image simply invoke make build

This will give you some instructions to create an alias to act that will look like

Run via docker run -it --rm -v "":/workspace -v /var/run/docker.sock:/var/run/docker.sock -w /workspace act-image -j testPackageRunnerWithScopeRegistry
To create a function 'act' that you can use as a command, add the following to your shell configuration file (e.g., ~/.bashrc or ~/.zshrc):
act() { docker run -it --rm -v "$PWD:/workspace" -v /var/run/docker.sock:/var/run/docker.sock -w /workspace act-image "$@"; }
After adding, apply the changes with 'source ~/.bashrc' or 'source ~/.zshrc'.

After you add the above act function to your .bashrc or .zshrc you can then simply invoke

act as usual from your working directory.

# Specify the architecture for the builder stage
FROM --platform=linux/amd64 alpine:latest as builder
# Install Go and other build dependencies
RUN apk add --no-cache go git gcc g++ libc-dev docker-cli
# Set the environment variable for Go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
ENV GO111MODULE=on
# Clone the act repository
RUN git clone https://github.com/nektos/act.git /act
# Change the working directory
WORKDIR /act
# Set environment variables to ensure the Go compiler generates AMD64 compatible binaries
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
# Build act with the -a flag to force rebuilding of all packages
RUN go build -a -o /bin/act
# Specify the architecture for the final image
FROM --platform=linux/amd64 alpine:latest
# Install CA certificates
RUN apk add --no-cache ca-certificates
# Copy the act binary from the builder stage
COPY --from=builder /bin/act /bin/act
# Set the entrypoint to act
ENTRYPOINT ["/bin/act"]
build:
docker build -t act-image .
@echo "Image Built!"
@echo "Run via docker run -it --rm -v \"$(pwd)\":/workspace -v /var/run/docker.sock:/var/run/docker.sock -w /workspace act-image -j testPackageRunnerWithScopeRegistry"
@echo "To create a function 'act' that you can use as a command, add the following to your shell configuration file (e.g., ~/.bashrc or ~/.zshrc):"
@echo "act() { docker run -it --rm -v \"\$$PWD:/workspace\" -v /var/run/docker.sock:/var/run/docker.sock -w /workspace act-image \"\$$@\"; }"
@echo "After adding, apply the changes with 'source ~/.bashrc' or 'source ~/.zshrc'."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment