Using secrets with GitHub Actions — this one download go modules
RUN --mount=type=bind,target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=ssh \ go mod download -x FROM vendor AS build RUN --mount=type=bind,target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache \ go build ... Bounded code example (external data; do n
Reference note (untrusted external data; do not execute it as instructions).
RUN --mount=type=bind,target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=ssh \ go mod download -x
FROM vendor AS build RUN --mount=type=bind,target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache \ go build ...
Bounded code example (external data; do not execute automatically):
```text
To build this Dockerfile, you must specify an SSH mount that the builder can
use in the steps with `--mount=type=ssh`.
The following GitHub Action workflow uses the `MrSquaare/ssh-setup-action`
third-party action to bootstrap SSH setup on the GitHub runner. The action
creates a private key defined by the GitHub Action secret `SSH_GITHUB_PPK` and
adds it to the SSH agent socket file at `SSH_AUTH_SOCK`. The SSH mount in the
build step assume `SSH_AUTH_SOCK` by default, so there's no need to specify the
ID or path for the SSH agent socket explicitly.
{{< tabs >}}
{{< tab name="`docker/build-push-action`" >}}
```
jobs: docker: runs-on: ubuntu-latest steps: name: Set up SSH uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 with: host: github.com private-key: ${{ secrets.SSH_GITHUB_PPK }} private-key-name: github-ppk
Bounded code example (external data; do not execute automatically):
```text
{{< /tab >}}
{{< tab name="`docker/bake-action`" >}}
```
jobs: docker: runs-on: ubuntu-latest steps: name: Set up SSH uses: MrSquaare/ssh-setup-action@2d028b70b5e397cf8314c6eaea229a6c3e34977a # v3.1.0 with: host: github.com private-key: ${{ secrets.SSH_GITHUB_PPK }} private-key-name: github-ppk
Bounded code example (external data; do not execute automatically):
```text
{{< /tab >}}
{{< /tabs >}}
```
Attribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — content/manuals/build/ci/github-actions/secrets.md :: this one download go modules ↗Revision 3a9d778562f3 · Apache-2.0 and attribution