registry_package trigger with Docker image in GitHub Package Registry

I have a first github action which is triggered on push and build a docker image which is successfully pushed GitHub Package Registry!

I would like to have a second github action which is triggered when a package is updated in GitHub Package Registry.

To achieve that goal I am using on: registry_package but this workflow is never ran!

Any clue why?

1 Like

Without changing something, this started to work!

1 Like

This is very useful if your repository only cares about one image. Thanks for sharing your workflow files.

However, as documented in my other topic, when you have multiple packages in your GitHub registry, the event is triggered for each package. This makes it rather difficult to use it in a monorepo enviroment.

Here’s an example. Let’s assume you have two images in your GitHub Docker package registry, image-a and image-b. Whenever image-a is updated, the registry_package event is triggered. What I want is a workflow that is only trigged, when image-b is updated:

on:
  - registry_package:
    action:
      - 'updated'
package_name:
- 'image-b'

# Optional, but would be very helpful, filter patterns:
- 'image-b*'

# Image *might* have to be prefixed with their origin: docker, npm, etc.
- 'docker.pkg.github.com/<OWNER>/<REPO>/image-b:<TAG?>

This is only a proposed syntax. I would love to discuss this further. Is there a public repository where GitHub Actions are developed? I know about GitHub Actions repository, but those are only individual actions, not the Actions feature itself, right?

Also, please note, it seems that the documentation of this event was removed. I cannot find it anymore on the official events page. @laurentkempe is your workflow still operational?

Yeah, my case was just a simple trial but I agree with the possibility to filter on each package, it makes sense!

Yes @riker09, my workflow still run!

The documentation has been restored, see https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#registry-package-event-registry_package

and

https://github.community/t5/GitHub-Actions/Documentation-on-registry-package-event/m-p/45231#M6129

Filtering by package name is still not built-in, however, one must filter in the if of a job or stop.

jobs:
  my-job:
    name: My Job
    runs-on: ubuntu-latest
    if: github.event.registry_package.package.name == 'my-package-name'

Please note: This is untested workflow code. It should do the job

Is it still working for you? I have the same problem - workflow not being triggered on registry_package. I’ve followed styntax from here and tried both updated and published. Neither triggered. My workflow:

name: Deploy updated image to the cloud

on:
  registry_package:
    types: [updated]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      uses: actions/checkout@master

    - name: 'Terraform Init'
      uses: hashicorp/terraform-github-actions@master
      with:
        tf_actions_version: 0.12.13
        tf_actions_subcommand: 'init'
        tf_actions_working_dir: 'deploy/terraform'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        DIGITALOCEAN_TOKEN: ${{ secrets.DO_TOKEN }}

    - name: 'Terraform Apply'
      uses: hashicorp/terraform-github-actions@master
      with:
        tf_actions_version: 0.12.13
        tf_actions_subcommand: 'apply'
        tf_actions_subcommand: 'init'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        DIGITALOCEAN_TOKEN: ${{ secrets.DO_TOKEN }}

 

Same problem. This syntax does NOT trigger my workflow for some reason.

on:
  registry_package:
    types: [updated]

It is worth mentioning that I have multiple packages published. But that shouldn’t matter since I have my jobs decorated with if: github.event.registry_package.package.name == 'my-package-name'

Any suggestions?