Skip to content

Commit

Permalink
fix: set authentication on dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lfbarrile01 committed Dec 2, 2024
1 parent 1561452 commit 988d95d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}

- name: Set up GitHub token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
Expand All @@ -44,6 +53,8 @@ jobs:
load: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:latest
build-args: |
GITHUB_TOKEN=${{ steps.app-token.outputs.token }}
- name: Extract tag name
shell: bash
Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ FROM node:22-alpine3.19
# Set the working directory in the container
WORKDIR /usr/src/app

# Set environment variable for GitHub token (if required)
# If you pass the GITHUB_TOKEN from your GitHub Actions as an environment variable
# this can be done as part of the build process.
ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=${GITHUB_TOKEN}

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Configure npm to use GitHub token for private packages (if needed)
RUN echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > ~/.npmrc

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

Expand Down

0 comments on commit 988d95d

Please sign in to comment.