DEV Community

Discussion on: How to build GitHub Actions in PHP with Minicli and Docker

Collapse
 
cicirello profile image
Vincent A. Cicirello

If you anticipate developing other actions with php, you might consider building a base image with all of the common stuff you'd need preinstalled, like git, curl, etc. The dockerfile for each action would then just need to add the action's code and set the entrypoint. An added benefit would be faster loading of the action since you wouldn't be installing stuff each time it runs.

For example, I maintain several GitHub Actions that are implemented in Python. I have a base Docker image that is a python image with git, curl, the GitHub CLI, and some other stuff preinstalled. So the Dockerfile of each action just needs to add the action's source.

Here's the repo to pyaction:

GitHub logo cicirello / pyaction

A base Docker image for Github Actions implemented in Python

pyaction

A base Docker image for Github Actions implemented in Python

Docker Image Version (latest by date) Docker Image Size (latest by date) Docker Pulls GitHub release (latest by date) build License

Summary

This Docker image is designed to support implementing Github Actions with Python. As of version 4.0.0., it starts with the official python docker image as the base which is a Debian OS. It specifically uses python:3-slim to keep the image size down for faster loading of Github Actions that use pyaction. On top of the base, we've installed curl gpg, git, and the GitHub CLI. We added curl and gpg because they are needed to install the GitHub CLI, and they may come in handy anyway (especially curl) when implementing a GitHub Action.

Note: Up through pyaction:3.14.0, we previously used Alpine Linux. However the GitHub CLI isn't currently supported on Alpine, which is why we have switched the base image.

Multiplatform Image

Version 4.0.0 and Newer: pyaction supports the following platforms:

  • linux/386
  • linux/amd64

It can be pulled from either Docker Hub or the GitHub Container Registry, probably faster from the latter when used in GitHub Actions.

And here is an action that uses it:

GitHub logo cicirello / count-action-users

Generates Shields endpoint with number of users of a GitHub Action

count-action-users

count-action-users

Check out all of our GitHub Actions: actions.cicirello.org/

About

GitHub release (latest by date) build samples CodeQL License GitHub top language

The cicirello/count-action-users GitHub Action generates a Shields endpoint with the count of the number of workflows that use a GitHub Action. It is thus a tool for maintainers of GitHub Actions, and it can be used to insert a badge with a users count into the README for a GitHub Action. The key features include:

  • Designed to Run on a Schedule: The intended usage is to run the action on a schedule (e.g., nightly) to update the endpoint.
  • Customizable: It is configurable in a number of ways (e.g., badge color, logo, style) using action inputs, but you can also override these things when you embed the badge using Shield's URL parameters.
  • Multiple Action Support: For those who maintain multiple GitHub Actions, the count-action-users action accepts a list of GitHub Actions as an input, generating endpoints for all…
Collapse
 
erikaheidi profile image
Erika Heidi

This is really great, thank you for sharing!