How can I use my own docker image in an action?

I recently discovered how to publish my own docker image to ghcr.io.
I thought it would be handy so I can use a custom configured image in my actions. That would save me precious time in every action-run for installing all kinds of utils I need.

How can I set the runs-on of a job to something so that it would use my custom image from ghcr.io?

Is this possible at all or am I misunderstanding something here?

I can imagine that it can only work if I base my custom image on one of the prepared GitHub runs-on images.


For those who are looking into their area:

I made an example at https://github.com/tombrus/example-docker-image-publish. It publishes an image and uses it in an action job. Check it out.

1 Like

You can do that with jobs.<job_id>.container, something like:

jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/your/image:latest
3 Likes

Great, this works! Thanks.

For those who are looking into their area:

I made an example at https://github.com/tombrus/example-docker-image-publish. It publishes an image and uses it in an action job. Check it out.

I took some inspiration from your https://github.com/airtower-luna/hello-ghcr repo @airtower-luna, thanks!

2 Likes