Skip to content

Commit

Permalink
Shared(Frontend): Start using npmAuthToken
Browse files Browse the repository at this point in the history
  • Loading branch information
pejamz committed May 9, 2022
1 parent 72c16f2 commit 0deb13d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ dist
!**/.yarn/plugins
!**/.yarn/releases
!**/.yarn/sdks
!**/.yarn/versions
!**/.yarn/versions
2 changes: 2 additions & 0 deletions docker-compose-akt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile.akt
args:
- GITHUB_REGISTRY_TOKEN=${GITHUB_REGISTRY_TOKEN}
ports:
- "4000:4000"
working_dir: /app/reactjs
Expand Down
2 changes: 2 additions & 0 deletions docker-compose-otr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile.otr
args:
- GITHUB_REGISTRY_TOKEN=${GITHUB_REGISTRY_TOKEN}
ports:
- "4000:4000"
working_dir: /app/reactjs
Expand Down
16 changes: 9 additions & 7 deletions docs/shared_frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ In this project directory, you can run:
## How to install the package?

1. Create an access token as instructed [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token), and select ONLY `read:packages` as the scope
2. Add the created token to yarn configs in `kieli-ja-kaantajatutkinnot/frontend/.yarnrc.yml` with the property name `npmAuthToken` as shown below
2. Add created token to your bash profile:

```sh
"opetushallitus":
npmRegistryServer: "https://npm.pkg.github.com"
npmAlwaysAuth: true
npmAuthToken: "created-token-here" # <-- Add this line!
PROFILE_ADDRESS=~/.zshrc # Depends on your current active profile. ~/.zshrc or ~/.bashrc
echo 'export GITHUB_REGISTRY_TOKEN="created_token_here"' >> $PROFILE_ADDRESS
```

3. Run `yarn add @opetushallitus/kieli-ja-kaantajatutkinnot.shared@version` to install the package
3. Reload bash profile configs

N:B: Do not push your token to git!
```sh
source $PROFILE_ADDRESS
```

4. Run `yarn add @opetushallitus/kieli-ja-kaantajatutkinnot.shared@version` to install the package
4 changes: 3 additions & 1 deletion frontend/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ enableTelemetry: false
nodeLinker: node-modules

npmScopes:
"@opetushallitus":
"opetushallitus":
npmRegistryServer: "https://npm.pkg.github.com"
npmAlwaysAuth: true
npmAuthToken: ${GITHUB_REGISTRY_TOKEN-GITHUB_TOKEN}

yarnPath: .yarn/releases/yarn-3.2.0.cjs
2 changes: 2 additions & 0 deletions frontend/Dockerfile.akt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM node:16.14.2-alpine

RUN corepack enable

ARG GITHUB_REGISTRY_TOKEN

# Create app directory
WORKDIR /app/reactjs

Expand Down
2 changes: 2 additions & 0 deletions frontend/Dockerfile.otr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM node:16.14.2-alpine

RUN corepack enable

ARG GITHUB_REGISTRY_TOKEN

# Create app directory
WORKDIR /app/reactjs

Expand Down

0 comments on commit 0deb13d

Please sign in to comment.