Auto: NPM_TOKEN을 찾지 λͺ»ν•œ GitHub μž‘μ—…

에 λ§Œλ“  2021λ…„ 02μ›” 22일  Β·  6μ½”λ©˜νŠΈ  Β·  좜처: intuit/auto

npm으둜 직접 κ²Œμ‹œν•˜λŠ” 것(잘 μž‘λ™ν•¨)μ—μ„œ 쑰직 λ²”μœ„ νŒ¨ν‚€μ§€ μ΄λ¦„μœΌλ‘œ GitHub νŒ¨ν‚€μ§€λ₯Ό μ‚¬μš©ν•˜λŠ” κ²ƒμœΌλ‘œ μ „ν™˜ν•˜λ €κ³  ν•©λ‹ˆλ‹€.

package.json μ—μ„œ νŒ¨ν‚€μ§€ 이름을 λ³€κ²½ν•˜κ³  ν•„μš”ν•œ publishConfig 예

"publishConfig": {
    "registry": "https://npm.pkg.github.com"
  },

그리고 λ¬Έμ„œμ— 따라 NPM_TOKEN NODE_AUTH_TOKEN λŒ€μ‹ 

 βœ”  success   Wrote authentication token string to /home/runner/.npmrc
⚠  warning   Error: Failed to replace env in config: ${NPM_TOKEN}

NPM_TOKEN λŠ” GitHub의 λ‚΄ μ €μž₯μ†Œ Secrets에 μ„€μ •λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

μ•‘μ…˜ 섀정은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

name: Publish

on:
  push:
    branches: [main]

jobs:
  release:
    runs-on: ubuntu-latest

    # this check needs to be in place to prevent a publish loop with auto and github actions
    if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"

    steps:
      - uses: actions/checkout<strong i="19">@v2</strong>
        with:
          # Needed for branch protection override
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Prepare repository
        run: git fetch --unshallow --tags

      - name: Use Node.js 12.x
        uses: actions/setup-node<strong i="20">@v1</strong>
        with:
          node-version: 12.x

      - name: Cache node modules
        uses: actions/cache<strong i="21">@v2</strong>
        with:
          path: node_modules
          key: node-modules-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            node-modules-${{ hashFiles('package-lock.json') }}

      - name: Create release
        env
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: |
          npm ci
          npm run build
          npm run release
question released

λͺ¨λ“  6 λŒ“κΈ€

GitHub νŒ¨ν‚€μ§€ λ ˆμ§€μŠ€νŠΈλ¦¬μ— κ²Œμ‹œν•˜κΈ° μœ„ν•œ μΆ”κ°€ 지침 이 μžˆμŠ΅λ‹ˆλ‹€.

NPM에 더 이상 κ²Œμ‹œν•˜μ§€ μ•ŠμœΌλ―€λ‘œ GitHub 토큰을 μ‚¬μš©ν•˜μ—¬ κ²Œμ‹œν•΄μ•Ό ν•©λ‹ˆλ‹€.

NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@hipstersmoothie λ§Žμ€ 도움을 μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. μ›λž˜ μž‘μ—…μ„ μ„€μ •ν•œ μ΄ν›„λ‘œ λ¬Έμ„œκ°€ μ—…λ°μ΄νŠΈλœ 것을 λ³΄μ•˜μ§€λ§Œ μ—¬μ „νžˆ λͺ¨λ“  단계가 ν¬ν•¨λ˜μ–΄ μžˆμ§€ μ•Šμ€ 것 κ°™μŠ΅λ‹ˆλ‹€. λ‚΄ λ…Έλ“œ 섀정에도 λ‹€μŒ 쀄을 μΆ”κ°€ν•΄μ•Ό ν–ˆμŠ΅λ‹ˆλ‹€(데λͺ¨ 리포지토리에 있음).

with:
          node-version: 14.x
          registry-url: 'https://npm.pkg.github.com'
          scope: '<strong i="7">@whiteorg</strong>'

λ‚˜λŠ” λ˜ν•œ μ—¬μ „νžˆ NPM_TOKEN κ²½κ³  λ©”μ‹œμ§€λ₯Ό 보고 μžˆμ—ˆμŠ΅λ‹ˆλ‹€. ν™˜κ²½ λΉ„λ°€λ‘œ λ‹€μ‹œ μΆ”κ°€ν•˜λ©΄ λ¬Έμ œκ°€ ν•΄κ²°λœ κ²ƒμœΌλ‘œ λ³΄μž…λ‹ˆλ‹€.

- name: Create release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

λ§ˆμ§€λ§‰μœΌλ‘œ, 이 λͺ¨λ“  섀정을 톡해 PR을 λ³‘ν•©ν•˜κ³  μžλ™μœΌλ‘œ μž‘μ—…μ„ μˆ˜ν–‰ν•˜μ—¬ μƒˆ νŒ¨ν‚€μ§€λ₯Ό μΆœμ‹œν•˜κ³  버전/λ³€κ²½ 둜그λ₯Ό μ—…λ°μ΄νŠΈν•  수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€ πŸŽ‰

κ·ΈλŸ¬λ‚˜ λ‚˜λŠ” μ£Όμœ„λ₯Ό λ§Œμ§€μž‘ κ±°λ¦¬λ©΄μ„œ λΆ„κΈ° 보호λ₯Ό λΉ„ν™œμ„±ν™”ν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μ‹œ ν™œμ„±ν™”ν•˜λ©΄ Autoκ°€ 버전 μ—…λ°μ΄νŠΈλ₯Ό μ»€λ°‹ν•˜λ €κ³  ν•  λ•Œλ§ˆλ‹€ μ‹€νŒ¨ν•˜λŠ” μƒˆλ‘œμš΄ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μŒκ³Ό 같이 κΈ°λ³Έ GITHUB_SECRET λŒ€μ‹  μƒˆ 개인 GitHub 토큰을 μΆ”κ°€ν•˜κ³  이λ₯Ό λΉ„λ°€λ‘œ μ°Έμ‘°ν•˜μ—¬ 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

- uses: actions/checkout<strong i="17">@v2</strong>
        with:
          # Needed for branch protection override
          token: ${{ secrets.GH_ADMIN_TOKEN }}

μ΅œμ„ μ˜ 해결책은 μ•„λ‹Œ 것 κ°™μœΌλ―€λ‘œ λˆ„κ΅¬λ“ μ§€ 더 λ‚˜μ€ 해결책을 μ•Œκ³  μžˆλ‹€λ©΄ κ°μ‚¬ν•˜κ² μŠ΅λ‹ˆλ‹€. λ˜λŠ” λ¬Έμ„œλ₯Ό μ—¬κΈ°μ—μ„œ μ—…λ°μ΄νŠΈν•΄μ•Ό ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€. https://intuit.github.io/auto/docs/build-platforms/github-actions#running -with-branch-protection

λ‚˜λŠ” κ·Έ λ¬Έμ„œλ₯Ό κ°œμ„ ν•˜κΈ° μœ„ν•΄ PR을 λ§Œλ“€μ—ˆμŠ΅λ‹ˆλ‹€. #1828을 κ²€ν† ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?

κ²€ν† , λͺ‡ 가지 μž‘μ€ μ œμ•ˆμ΄μ§€λ§Œ λͺ¨λ‘ μ’‹μ•„ λ³΄μž…λ‹ˆλ‹€ ☺ λͺ¨λ“  도움에 λ‹€μ‹œ ν•œλ²ˆ κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€


:rocket: v10.16.8 μ—μ„œ λ°œν–‰λœ 문제 :rocket:

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰