Search code examples
deploymentgithub-actionsgithub-pagespnpm

can't deplopy to github pages with pnpm?


i am new to github actions and made a recent question here on stackoverflow got the part i needed answered but endup facing another issue the script won't deploy and give the final url.

name: pnpm Example Workflow
on:
push:
jobs:
 build:
 runs-on: ubuntu-latest
   strategy:
    matrix:
     node-version: [18]
    steps:
    - uses: actions/checkout@v3
    - uses: pnpm/action-setup@v2
       with:
       version: 7
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
       with:
       node-version: ${{ matrix.node-version }}
       cache: 'pnpm'
    - name: Install dependencies
       run: pnpm install
    - name: Build
       run: pnpm run build
   deploy:
   environment:
     name: github-pages
    #  url: ${{steps.deployment.outputs.page_url}}
   runs-on: ubuntu-latest
    steps:

 - name: Setup Pages
   uses: actions/configure-pages@v3
 - name: Upload artifact
    uses: actions/upload-pages-artifact@v1
    with:
     # Upload dist repository
    path: .
  - name: Deploy
   - name: Deploy
     uses: peaceiris/actions-gh-pages@v3
      with:
     github_token: ${{ secrets.GITHUB_TOKEN }}
      publish_dir: ./public

something went wrong along the way and i don't know how to proceed from here can any one pin point my mistake

edit: after i formated script i got this error :

deploy Environment URL '' is not a valid http(s) URL, so it will not be shown as a link in the workflow graph.


Solution

  •  name: pnpm Example Workflow
    on:
      push: 
      branches: [ master]
    
     permissions:
       contents: read
       pages: write
       id-token: write
    
     jobs:
       build:
        environment:
        name: github-pages
      url: ${{steps.deployment.outputs.page_url}}
    runs-on: ubuntu-latest
    
    strategy:
      matrix:
        node-version: [18]
    steps:
      - uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2
        with:
          version: 7
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: pnpm
      - name: Install dependencies
        run: pnpm install
      - name: Build
        run: pnpm run build
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          # Upload dist repository
           path: ./dist
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1
    

    This is the solution to my question