Skip to content

Conversation

@aduh95
Copy link

@aduh95 aduh95 commented Jun 15, 2025

See https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions

Tested with https://github.com/nodejs/node-core-utils/actions/runs/15667322080/job/44133183235

It allows to use the action from a fork / on a specific commit. It shouldn't be a breaking change as the default is left unchanged.

@aduh95 aduh95 marked this pull request as draft June 15, 2025 17:55
@aduh95 aduh95 marked this pull request as ready for review June 15, 2025 21:18
@aduh95 aduh95 changed the title fix: pin the action versions feat: add options to load the action from a specific repo/ref Jun 15, 2025
@aduh95 aduh95 requested a review from ljharb June 15, 2025 21:57
type: string

action-repository:
description: "Repository to load the actions from"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we want the repository to be overrideable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of forks. I've used it to test this very PR


action-ref:
description: "Git ref to load the actions from"
default: ${{ github.ref || 'v0.1.10' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a version script at the root that used to update this version during npm version: https://github.com/pkgjs/action/blob/main/package.json#L9 - not sure what's the best approach for it now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, when would github.ref not be set?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, when would github.ref not be set?

As the docs say: This is only set if a branch or tag is available for the event type.
From my own testing, workflow_call leaves this undefined, although couldn't find where that's defined in the docs.


action-repository:
description: "Repository to load the actions from"
default: ${{ github.repository || 'pkgs/action' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does github.repository refer to here? Would that not be the repository that sets uses: pkgjs/action, i.e. it will always try to check out the local copy (which probably won't exist), rather than the pkgjs/action itself?

I could be misinterpreting this, of course.

Additionally, when would github.repository not be set at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does github.repository refer to here?

On workflow_call: it's undefined. Otherwise, it's the name of the repo, as you can see in https://github.com/aduh95/action/actions/runs/15821306998, it takes the name of the fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants