I was experiencing GPG errors when trying to install packages using apt when using GitHub Actions.

The errors I was seeing were similar to the following:

Err:16 http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease
  The following signatures were invalid: ERRSIG 4F4EA0AAE5267A6C
Reading package lists...
W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease: The following signatures were invalid: ERRSIG 4F4EA0AAE5267A6C
E: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu jammy InRelease' is not signed.

Since I didn't really need that repository in the action, I fixed the issue by removing the repository from the action.

sudo add-apt-repository --remove ppa:ondrej/php

After the removal, don't forget to clean the package cache:

sudo apt-get clean