actions / deploy-pages

GitHub Action to publish artifacts to GitHub Pages for deployments
https://pages.github.com
MIT License
671 stars 79 forks source link

Problem in page deployment with vuejs vite to github page #342

Closed daironpf closed 7 months ago

daironpf commented 7 months ago

Hello, I am deploying my page in vuejs vite(is the frontend of open source project) to github page with github action but the artifact is giving me an error, could someone help me with this problem. Greetings

I attach the photo of my error and the link to my github action. error

here the link to the action file

daironpf commented 7 months ago

i make some changes in the code and now the error is this: error completo

daironpf commented 7 months ago

This is the code of my action

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ['main']

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: 'pages'
  cancel-in-progress: true

jobs:
  # Single deploy job since we're just deploying
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: 'frontend'
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set up Node
        uses: actions/setup-node@v2
        with:
          node-version: 20
          cache: 'npm'
          cache-dependency-path: '**/package-lock.json'
      - name: Install dependencies
        run: npm ci        
      - name: Build      
        run: npm run build
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: /dist
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          source: dist
yoannchaudet commented 7 months ago

Try changing the path from /dist to ./dist. Removing the slash altogether could work too.

daironpf commented 7 months ago

Try changing the path from /dist to ./dist. Removing the slash altogether could work too.

  1. change:

    • name: Upload artifact uses: actions/upload-artifact@v4 with: name: dist path: ./dist Result: Error. throw this wairning at the same time of error: No files were found with the provided path: ./dist. No artifacts will be uploaded.
  2. change: uses: actions/upload-artifact@v4 with: name: dist path: dist Result:

second error

yoannchaudet commented 7 months ago

oh never mind did not see:

        working-directory: 'frontend'

Your artifacts' location is ./frontend/dist.

daironpf commented 7 months ago

oh never mind did not see:

        working-directory: 'frontend'

Your artifacts' location is ./frontend/dist.

This is my new code and have the same error:

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ['main']

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: 'pages'
  cancel-in-progress: true

jobs:
  # Single deploy job since we're just deploying
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: 'frontend'
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set up Node
        uses: actions/setup-node@v2
        with:
          node-version: 20
          cache: 'npm'
          cache-dependency-path: '**/package-lock.json'
      - name: Install dependencies
        run: npm ci        
      - name: Build      
        run: npm run build
      - name: Deploy to GitHub Pages
        uses: actions/configure-pages@v4
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: dist
          path: ./frontend/dist
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          source: dist

Here is the link to the .yml file

yoannchaudet commented 7 months ago

If you check your last run: https://github.com/daironpf/SocialSeed/actions/runs/8902313032

You can see that your artifact has been published. It is named dist because you are specifying a custom artifact name.

That's all good but for actions/deploy-pages you are not passing dist in the right place. We don't have a source input. We have an artifact_name one.

So this line specifically is wrong: https://github.com/daironpf/SocialSeed/blob/2859f681d9fcd329e91f42b78bb3ab989684aa9d/.github/workflows/jekyll-gh-pages.yml#L58

Replace it with:

artifact_name: dist

That should go further.

yoannchaudet commented 7 months ago

https://github.com/daironpf/SocialSeed/pull/47

👋