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

feat: add npm authentication for secure publishing #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 22 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,32 @@
name: Lint, Format, and Deploy
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

on:
push:
branches:
- main
pull_request:
branches:
- main
name: Node.js Package

permissions:
contents: write
on:
release:
types: [created]

jobs:
lint-and-format:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install JSHint and JS Beautifier
run: |
sudo apt update
sudo apt install -y python3-pip
pip3 install jshint jsbeautifier

- name: Run JSHint (Linting)
run: jshint . --exclude=node_modules

- name: Run JS Beautifier (Formatting)
run: js-beautify -r **/*.js
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test

deploy:
needs: lint-and-format
publish-npm:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
branch: gh-pages
folder: .
node-version: 20
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.group13access}}