Hello this is my submission for the Github Actions hackaton!
I actually developed this for my organization but it is really useful for installing private npm modules (in this case hosted on github)
You gotta pass these inputs:
org_name
Organization name (Github repository name)
auth_token
AuthToken that is able to download files from the repository, can also be passed as env and it's rather recommended this way
And you use it like in the example on below
My Workflow
name: core
on:
pull_request
jobs:
continous-integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Create a .npmrc file for the github private repository
uses: FerLuisxd/create-npmrc@3
with:
org_name: lig0
env:
AUTH_TOKEN: ${{ secrets.OGIL_PALOMA_SECRET }}
- run: npm install
- run: npm run lint
- run: npm test
env:
CI: true
Submission Category:
DIY Deployments
Yaml File or Link to Code
FerLuisxd / create-npmrc
Github workflow action to create .npmrc file for github to the root folder
Create a .npmrc file for the github repository
Github workflow action to create .npmrc file for github to the root folder
Pass all sensitive data using secrets.
Inputs
org_name
Organization name (Github repository name)
auth_token
AuthToken that is able to download files from the repository, can also be passed as env and it's rather recommended this way
Example usage
uses: ferluisxd/create-npmrc@3
with:
org_name: lig0
auth_token: 31352d11daasdf769942919dsafas594a5d
env:
AUTH_TOKEN: ${{ secrets.github_auth_token }}
Example output
registry = https://npm.pkg.github.com/lig0
//npm.pkg.github.com/:_authToken=31352d11daasdf769942919dsafas594a5d
π Congratulations, you have successfully automated your private module installs! π
Additional Resources / Info
If you need to know more about installing private modules click (here)[https://docs.github.com/pt/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages]
Top comments (1)
Nice! And great to see you around Luis