Skip to content

Instantly share code, notes, and snippets.

@vorant94
Last active September 7, 2023 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vorant94/13f0d36b3a715256442b9ea8cd2b003e to your computer and use it in GitHub Desktop.
Save vorant94/13f0d36b3a715256442b9ea8cd2b003e to your computer and use it in GitHub Desktop.
passing secrets from gh action to docker builder
...
COPY package*.json ./
RUN --mount=type=secret,id=npmrc,target=/usr/local/app/.npmrc \
npm ci
...
...
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Create authenticated .npmrc for Docker build runner
run: |
echo "//npm.pkg.github.com/:_authToken=${{ github.token }}" > $HOME/.npmrc
cat .npmrc >> $HOME/.npmrc
echo "npmrc_path=$HOME/.npmrc" >> "$GITHUB_ENV"
- name: Build and push
uses: docker/build-push-action@v4
with:
push: false
tags: vorant94-io/web:latest
secret-files: |
npmrc=${{ env.npmrc_path }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment