Skip to content

Conversation

@sethvargo
Copy link
Contributor

@sethvargo sethvargo commented Jul 10, 2025

The GitHub Action currently puts generated credentials into $GITHUB_WORKSPACE (/github/workspace). Unfortunately this is also the working directory of the checkout, so it's too easy to accidentally bundle the generated credentials into Docker containers, binaries, or anything that uses * or . as a build context.

In the past, we tried to move the exported credentials into RUNNER_TEMP or other directories, but it always introduced incompatibility with the various community workflows (Docker, self-hosted, etc.):

While undocumented, it appears that /github/home is an understood path, AND that path is mounted into Docker containers. That means we can export credentials outside of the workspace and still have them available inside the Docker container without users taking manual actions. This comes at three major costs:

  1. We have to write the file into two locations. This isn't ideal, but it's also not the end of the world. Apparently there's some magical path rewriting that GitHub Actions does. If we set the output to the temp path, it gets rewritten into the container.

  2. We would be relying on an undocumented filepath which GitHub could change at any point in the future. Since this is not part of the publicly-documented API, GitHub is within their rights to change this without notice, potentially breaking everyone/everything. Here was GitHub's feedback when we asked about the feature:

    /github/home was there for back-compat with non-yaml Actions created 5+ years back, i would not recommend customers to use it.

    That folder is not mounted into service container since non-yaml Actions didn't have service container concept.

    We probably don't want to document this legacy info.

  3. Because of the previous point, there are no environment variables that export these paths. We have to dynamically compile them, and it's a bit hacky.

@sethvargo sethvargo force-pushed the sethvargo/github_home branch 6 times, most recently from 73bdd63 to 7f48ce7 Compare July 11, 2025 14:11
The GitHub Action currently puts generated credentials into $GITHUB_WORKSPACE (/github/workspace). Unfortunately this is also the working directory of the checkout, so it's too easy to accidentally bundle the generated credentials into Docker containers, binaries, or anything that uses `*` or `.` as a build context.

In the past, we tried to move the exported credentials into RUNNER_TEMP or other directories, but it always introduced incompatibility with the various community workflows (Docker, self-hosted, etc.):

- google-github-actions/setup-gcloud#148
- google-github-actions/setup-gcloud#149
- google-github-actions/setup-gcloud#405
- google-github-actions/setup-gcloud#412

While undocumented, it appears that `/github/home` is an understood path, AND that path is mounted into Docker containers. That means we can export credentials outside of the workspace and still have them available inside the Docker container without users taking manual actions. This comes at three major costs:

1. We have to write the file into two locations. This isn't ideal, but it's also not the end of the world.

2. We would be relying on an undocumented filepath which GitHub could change at any point in the future. Since this is not part of the publicly-documented API, GitHub is within their rights to change this without notice, potentially breaking everyone/everything.

3. Because of the previous point, there are no environment variables that export these paths. We have to dynamically compile them, and it's a bit messy.
@sethvargo sethvargo force-pushed the sethvargo/github_home branch from 7f48ce7 to 3b2dd40 Compare July 11, 2025 14:23
@alsutton
Copy link

alsutton commented Nov 6, 2025

Would RUNNER_TEMP be a better place? That would ensure that the token file is cleaned up after every run.

Ref; RUNNER_TEMP in https://docs.github.com/en/actions/reference/workflows-and-actions/variables

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants