Skip to content

Conversation

raviyadav2509
Copy link
Contributor

@raviyadav2509 raviyadav2509 commented Sep 23, 2025

New GitHub Actions Workflows

Test and Publish Workflow (test-and-publish.yml)

  • Runs tests, linting, and building on all branches
  • Publishes to NPM only when changes are merged to main
  • Uses Node.js 22.15.1 with Yarn caching for performance
  • Includes CodeQL security scanning

Release Workflow (release.yml)

  • Automatically creates Release PRs from develop to main
  • Triggered when changesets are detected on develop branch
  • Integrates seamlessly with changeset versioning system

Security Enhancements

  • Added prepublishOnly scripts to prevent manual NPM publishing
  • Configured minimal GitHub token permissions for security
  • NPM authentication via secure NPM_TOKEN secret

Configuration Updates

  • Updated .gitignore for build artifacts and temporary files
  • Enhanced package.json with publishing protection scripts

Setup Requirements

Before merging, ensure:

  • NPM_TOKEN secret is configured in repository settings with publish access to @ag.ds-next
  • Branch protection rules are configured for main branch

Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: 78c3447

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ag.ds-next/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements automated NPM publishing with GitHub Actions, replacing manual publishing with a secure CI/CD pipeline that integrates with changesets for version management.

  • Adds automated test-and-publish workflow that runs tests/linting on all branches and publishes to NPM only on main branch merges
  • Implements release workflow to automatically create Release PRs from develop to main when changesets are detected
  • Adds security safeguards including prepublishOnly scripts to prevent manual publishing and minimal GitHub token permissions

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/test-and-publish.yml New workflow for CI/CD pipeline with testing, building, and NPM publishing
.github/workflows/release.yml Updated release workflow with explicit security permissions
package.json Added prepublishOnly script to prevent manual publishing
packages/react/package.json Added prepublishOnly script to prevent manual publishing
.changeset/lucky-sheep-trade.md Changeset documenting the automated NPM publishing feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +86 to +93
- name: Configure npm for public publishing
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
echo "@ag.ds-next:registry=https://registry.npmjs.org" >> ~/.npmrc
echo "access=public" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NPM configuration writes the auth token to ~/.npmrc in plain text. Consider using the NODE_AUTH_TOKEN environment variable with actions/setup-node's built-in registry authentication instead, which is more secure and already configured on line 81.

Suggested change
- name: Configure npm for public publishing
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
echo "@ag.ds-next:registry=https://registry.npmjs.org" >> ~/.npmrc
echo "access=public" >> ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# Removed insecure step that writes auth token to ~/.npmrc.
# If you need to set registry or access for scoped packages, add a step like:
# - name: Configure npm registry and access
# run: |
# echo "@ag.ds-next:registry=https://registry.npmjs.org" >> ~/.npmrc
# echo "access=public" >> ~/.npmrc

Copilot uses AI. Check for mistakes.

echo "Publishing packages to NPM registry..."
yarn publish-changed
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both NPM_TOKEN and NODE_AUTH_TOKEN are set to the same secret value, which creates redundancy. Since NODE_AUTH_TOKEN is the standard environment variable used by actions/setup-node for NPM authentication, you can remove NPM_TOKEN and rely solely on NODE_AUTH_TOKEN.

Suggested change
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Sep 23, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://agriculturegovau.github.io/agds-next/pr-preview/pr-2119/

Built to branch gh-pages at 2025-09-23 23:53 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant