| Title: | Pin 'GitHub' Actions to 'SHA' |
|---|---|
| Description: | Harden your 'GitHub' workflow security by pinning your third-party actions to the appropriate 'SHA'. |
| Authors: | Zhian N. Kamvar [aut, cre] (ORCID: <https://orcid.org/0000-0003-1458-7108>), Becky Sweger [ctb] |
| Maintainer: | Zhian N. Kamvar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-31 09:49:59 UTC |
| Source: | https://github.com/zkamvar/pinsha |
Automatically pin all actions to their expected hashes in your GitHub workflows
pin( workflows = ".github/workflows", include_official = FALSE, write = FALSE, verbose = TRUE )pin( workflows = ".github/workflows", include_official = FALSE, write = FALSE, verbose = TRUE )
workflows |
the directory to your github workflows |
include_official |
when |
write |
When |
verbose |
when |
nothing. Used for its side-effect
tmp <- withr::local_tempdir() workflows <- fs::path(tmp, ".github", "workflows") fs::dir_copy(system.file("workflows", package = "pinsha"), workflows) withr::with_dir(tmp, pin_find_actions(".github/workflows")) withr::with_dir(tmp, pin(write = TRUE)) withr::with_dir(tmp, pin_find_actions(".github/workflows"))tmp <- withr::local_tempdir() workflows <- fs::path(tmp, ".github", "workflows") fs::dir_copy(system.file("workflows", package = "pinsha"), workflows) withr::with_dir(tmp, pin_find_actions(".github/workflows")) withr::with_dir(tmp, pin(write = TRUE)) withr::with_dir(tmp, pin_find_actions(".github/workflows"))
Pin an individual action to its corresponding SHA
pin_action(action = "r-lib/actions/check-r-package@v2")pin_action(action = "r-lib/actions/check-r-package@v2")
action |
the action written with github syntax that contains at least the github user, repo, and tag |
the same action with an SHA and a comment that indicates the tag the sha belongs to (this may be different than the tag if you use a floating tag)
# pin a specific release pin_action("r-lib/actions/check-r-package@v2") # pin the latest release pin_action("docker/login-action")# pin a specific release pin_action("r-lib/actions/check-r-package@v2") # pin the latest release pin_action("docker/login-action")
Pin a third-party action in a workflow
pin_action_workflow( action = "r-lib/actions/check-r-package@v2", replacement = NULL, workflow = ".github/workflows/R-CMD-check.yaml", write = FALSE )pin_action_workflow( action = "r-lib/actions/check-r-package@v2", replacement = NULL, workflow = ".github/workflows/R-CMD-check.yaml", write = FALSE )
action |
the action written with github syntax that contains at least the github user, repo, and tag |
replacement |
(optional) the replacement for the particular action. If
this is not provided (default), |
workflow |
the path to a github workflow file |
write |
if |
a character vector of the workflow file with the actions replaced.
pkgdown <- withr::local_tempdir() fs::file_copy(system.file("workflows", "pkgdown.yaml", package = "pinsha"), pkgdown) actions <- pin_find_actions(pkgdown) actions for (action in actions) pin_action_workflow(action, workflow = pkgdown, write = TRUE) pin_find_actions(pkgdown)pkgdown <- withr::local_tempdir() fs::file_copy(system.file("workflows", "pkgdown.yaml", package = "pinsha"), pkgdown) actions <- pin_find_actions(pkgdown) actions for (action in actions) pin_action_workflow(action, workflow = pkgdown, write = TRUE) pin_find_actions(pkgdown)
Find GitHub actions used in a workflow file
pin_find_actions( workflow = ".github/workflows/R-CMD-check.yaml", include_official = FALSE )pin_find_actions( workflow = ".github/workflows/R-CMD-check.yaml", include_official = FALSE )
workflow |
the path to a github workflow file |
include_official |
when |
a character vector of zero or more actions used in your workflows
workflows <- system.file("workflows", package = "pinsha") pin_find_actions(workflows) pkgdown <- system.file("workflows", "pkgdown.yaml", package = "pinsha") pin_find_actions(pkgdown)workflows <- system.file("workflows", package = "pinsha") pin_find_actions(workflows) pkgdown <- system.file("workflows", "pkgdown.yaml", package = "pinsha") pin_find_actions(pkgdown)