Skip to content
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

Support Github App #116

Closed
matanbaruch opened this issue Jul 7, 2023 · 2 comments · Fixed by #118
Closed

Support Github App #116

matanbaruch opened this issue Jul 7, 2023 · 2 comments · Fixed by #118
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@matanbaruch
Copy link

Hey,
Is it possible to use this Github Action using Github App?
We would like to not use Personal Access Token of individual and use a Github App credentials to publish packages

@mcous
Copy link
Member

mcous commented Jul 7, 2023

Hi @matanbaruch! I assume that you are asking about publishing to the GitHub registry, since you're referring to GitHub tokens rather than npm tokens.

There is no need to create a Personal Access Token to use this action to publish to the GitHub Registry. Every GitHub Actions job is given a temporary access token automatically, accessible via secrets.GITHUB_TOKEN. To use it to publish a package, define your workflow to give that token publishing permission:

name: Publish package to GitHub Packages

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    permissions:
      contents: read
      packages: write  # < allow the built-in token to publish packages
    
    steps:
      - uses: actions/checkout@v3
      
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      
      - run: npm ci
      
      # ... your project's specific build steps ...
      
      - uses: JS-DevTools/npm-publish@v2
        with:
          registry: 'https://npm.pkg.github.com'
          token: ${{ secrets.GITHUB_TOKEN }}

Edit: I forgot the registry input when I first commented! Fixed my snippet by adding it

@mcous mcous added question Further information is requested documentation Improvements or additions to documentation labels Jul 7, 2023
@mcous mcous closed this as completed in #118 Jul 9, 2023
@mcous
Copy link
Member

mcous commented Jul 9, 2023

I added the above snippet to the README. Hopefully this example helps!

Because GitHub Actions has ephemeral access tokens built in, I don't see a need for a GitHub Apps integration, so I closed the issue. Please let me know if you have any more questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants