Skip to content

Add permissions

Add permissions #12

name: Node.js Package
on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize]
branches: ['main']
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Retrieve NPM Token'
id: vault
uses: hashicorp/vault-action@v2.4.3
with:
url: ${{ secrets.VAULT_URL }}
role: ${{ github.event.repository.name }}-github-action
method: jwt
path: github-actions
exportEnv: false
secrets: |
secret/data/github/github_packages_read GITHUB_PACKAGES_READ_TOKEN | GITHUB_PACKAGES_READ_TOKEN ;
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@contentful'
always-auth: true
- name: 'Create GH .npmrc'
shell: bash
run: |
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > ~/.npmrc
echo "@contentful:registry=https://npm.pkg.github.com" >> ~/.npmrc
env:
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_PACKAGES_WRITE_TOKEN }}
- run: npm ci
- run: npm run build
- run: npm test
- run: |
npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.vault.outputs.GITHUB_TOKEN }}
NPM_TOKEN: ${{ steps.vault.outputs.GITHUB_PACKAGES_WRITE_TOKEN }}