Skip to content

Commit

Permalink
Refactor publish workflow to clone repository, initialize submodules,…
Browse files Browse the repository at this point in the history
… and authenticate with npm

- Cloned the repository to a temporary directory
- Initialized and updated submodules
- Downloaded modified files
- Set up Node.js environment
- Installed can-npm-publish package as a dev dependency
- Created .temp-npmrc file for npm authentication
- Checked git status in the temporary repository
- Published package if needed using can-npm-publish and npm commands
  • Loading branch information
zanhk committed Sep 17, 2023
1 parent 46e5fd0 commit c5284fd
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,46 @@ jobs:
publish-gpr:
needs: bump-version
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: "Checkout source code"
uses: actions/checkout@v3

# Clone the repository to a temporary directory
- name: "Clone repository to temp directory"
run: git clone ${{ github.event.repository.clone_url }} temp-repo

# Initialize and update submodules
- name: "Initialize submodules"
run: |
cd temp-repo
git submodule update --init --recursive
- name: "Download modified files"
uses: actions/download-artifact@v3
with:
name: modified-files

- name: "Setup node"
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: "Install can-npm-publish"
run: |
cd temp-repo
npm install can-npm-publish --save-dev
- name: Setup .temp-npmrc file to authenticate with npm
run: |
cd temp-repo
echo "//registry.npmjs.org/:_authToken=${{ env.NPM_TOKEN }}" > .temp-npmrc
- name: "Git status check"
run: git status
run: |
cd temp-repo
git status
- name: "Publish package if needed"
run: npx can-npm-publish --verbose && npm publish --no-git-checks --userconfig .temp-npmrc || echo "Does not publish"
run: |
cd temp-repo
npx can-npm-publish --verbose && npm publish --no-git-checks --userconfig .temp-npmrc || echo "Does not publish"

0 comments on commit c5284fd

Please sign in to comment.