Network policy needs
safedep/[email protected] or later. Use it with enforce: true. Without kernel enforcement, a process can ignore the proxy variables and connect directly. See PMG in GitHub Actions.Build the policy from a run
The proxy records every destination that a job reaches. Run the job once with no policy, then turn the run into a profile.1
Add the proposal steps to the job
PMG_PROXY_RUN. The run ID comes from the event log, so do not set skip-event-logging: true.2
Run the workflow and download the artifact
The
pmg-network.yml file has one allow rule for each host that the job reached, and a rule that denies every other destination.3
Review and commit the profile
Remove each host that the job does not need. Commit the file as
.pmg/profiles/ci.yml.4
Protect the profile
The profile controls what the job can reach, so give it the same review as the workflow file. Add a
CODEOWNERS line:Enforce the policy
Setnetwork-profile and network-mode on the action. Remove the proposal steps.
network-mode: audit and the proposal steps. In the proposal step, use --into .pmg/profiles/ci.yml in place of --new pmg-network.yml, and upload .pmg/profiles/ci.yml. In enforce mode, the proxy refuses a new destination, so the proposal gets no rule for it.
Next steps
For the steps withoutenforce and the steps with config-file, see Build the profile from a run in the PMG action documentation. For the input table, see Inputs.
PMG in GitHub Actions
Set up the PMG action and kernel enforcement.
Limit the Hosts a Package Install Can Reach
Apply a network policy on a developer machine.

