-
Notifications
You must be signed in to change notification settings - Fork 8.2k
docs: address issue #23189 #24114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
github-actions
wants to merge
1
commit into
main
Choose a base branch
from
agent/issue-23189
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+113
−8
Open
docs: address issue #23189 #24114
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -57,14 +57,119 @@ jobs: | |||||
| "github_token=${{ secrets.GITHUB_TOKEN }}" | ||||||
| ``` | ||||||
|
|
||||||
| > [!NOTE] | ||||||
| > | ||||||
| > You can also expose a secret file to the build with the `secret-files` input: | ||||||
| > | ||||||
| > ```yaml | ||||||
| > secret-files: | | ||||||
| > "MY_SECRET=./secret.txt" | ||||||
| > ``` | ||||||
| ### Using secret files | ||||||
|
|
||||||
| The `secret-files` input lets you mount existing files as secrets in your build. | ||||||
| This is useful when you need to use credential files that are generated during your workflow, | ||||||
| or when you need to mount configuration files like `.npmrc` or `.pypirc` that are already in the expected format. | ||||||
|
|
||||||
| The key difference between `secrets` and `secret-files`: | ||||||
|
|
||||||
| - `secrets` - Pass secret values as strings (from environment variables or GitHub secrets) | ||||||
| - `secret-files` - Mount existing files from the runner's filesystem | ||||||
|
|
||||||
| #### Example: Using .npmrc for private npm packages | ||||||
|
|
||||||
| If your build needs to install packages from a private npm registry, | ||||||
| you can create an `.npmrc` file and mount it as a secret: | ||||||
|
|
||||||
| ```yaml | ||||||
| name: ci | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
|
|
||||||
| jobs: | ||||||
| docker: | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Docker Buildx | ||||||
| uses: docker/setup-buildx-action@{{% param "setup_buildx_action_version" %}} | ||||||
|
|
||||||
| - name: Create .npmrc file | ||||||
| run: | | ||||||
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | ||||||
|
|
||||||
| - name: Build | ||||||
| uses: docker/build-push-action@{{% param "build_push_action_version" %}} | ||||||
| with: | ||||||
| context: . | ||||||
| secret-files: | | ||||||
| "npmrc=./.npmrc" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quotes not needed with the input list parser
Suggested change
|
||||||
| tags: user/app:latest | ||||||
| ``` | ||||||
|
|
||||||
| In your Dockerfile, mount the secret file to the expected location: | ||||||
|
|
||||||
| ```dockerfile | ||||||
| # syntax=docker/dockerfile:1 | ||||||
| FROM node:20-alpine | ||||||
|
|
||||||
| WORKDIR /app | ||||||
|
|
||||||
| COPY package*.json ./ | ||||||
|
|
||||||
| RUN --mount=type=secret,id=npmrc,target=/root/.npmrc \ | ||||||
| npm ci | ||||||
|
|
||||||
| COPY . . | ||||||
|
|
||||||
| RUN npm run build | ||||||
| ``` | ||||||
|
|
||||||
| #### Example: Using dynamically generated credentials | ||||||
|
|
||||||
| You can generate credential files from multiple secrets and mount them: | ||||||
|
|
||||||
| ```yaml | ||||||
| name: ci | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
|
|
||||||
| jobs: | ||||||
| docker: | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Docker Buildx | ||||||
| uses: docker/setup-buildx-action@{{% param "setup_buildx_action_version" %}} | ||||||
|
|
||||||
| - name: Create credentials file | ||||||
| run: | | ||||||
| cat <<EOF > aws-credentials | ||||||
| [default] | ||||||
| aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID }} | ||||||
| aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||||||
| EOF | ||||||
|
|
||||||
| - name: Build | ||||||
| uses: docker/build-push-action@{{% param "build_push_action_version" %}} | ||||||
| with: | ||||||
| context: . | ||||||
| secret-files: | | ||||||
| "aws=./aws-credentials" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here
Suggested change
|
||||||
| tags: user/app:latest | ||||||
| ``` | ||||||
|
|
||||||
| In your Dockerfile: | ||||||
|
|
||||||
| ```dockerfile | ||||||
| # syntax=docker/dockerfile:1 | ||||||
| FROM alpine | ||||||
|
|
||||||
| RUN apk add --no-cache aws-cli | ||||||
|
|
||||||
| RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \ | ||||||
| aws s3 cp s3://my-private-bucket/data.tar.gz /tmp/ | ||||||
| ``` | ||||||
|
|
||||||
| ### Multi-line secrets | ||||||
|
|
||||||
| If you're using [GitHub secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) | ||||||
| and need to handle multi-line value, you will need to place the key-value pair | ||||||
|
|
||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to latest stable
Maybe we should have this defined in hugo config