I use github action and vercel to deploy my project(vite+react+pnpm) to vercel, action said error: "Error: spawn pnpm ENOENT" - github

when I push my github project, the github action was executed, but it failed, the error message from the action is below:
Run vercel build --prod --token=***
Vercel CLI 28.10.3
Detected `pnpm-lock.yaml` generated by pnpm 7...
Installing dependencies...
Error: spawn pnpm ENOENT
Error: Process completed with exit code 1.
this is my action yml settings:
name: Vercel Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- master
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: 18.12.1
- name: Install Vercel CLI
run: npm install --global vercel#latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

I got this same error too, but I fixed it by
install pnpm first
install the Vercel CLI via pnpm add --global vercel#latest:
jobs:
deploy-production:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Install Node.js
uses: actions/setup-node#v3
with:
node-version: 18
- uses: pnpm/action-setup#v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Install Vercel CLI
run: pnpm add --global vercel#latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

Related

I can't able to upload an artifact to GitHub

there I am facing some issues with my workflow artefacts. The Error is
-(Error: Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts )
I create a zip and then upload it to artefacts does not work. and I delete my old artefacts still I'm facing this issue. I tried so many ways to upload artefacts but nothing worked for me.
I'm sharing my workflow:
name: Build and Deploy My App
on:
push:
branches: [master]
workflow_dispatch:
jobs:
build:
name: Creating Build βš’
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#main
- name: setup Node Version To 16
uses: actions/setup-node#v2
with:
node-version: '16.x'
- name: Installing Packages πŸ“¦
run: npm install --legacy-peer-deps
- name: πŸ”¨ Build Project
run: CI=false npm run build
- name: zip the build folder
run: zip release.zip ./build/** -r
- name: Archive production artifact
uses: actions/upload-artifact#v3
with:
name: my-app-build
path: release.zip
deploy:
name: Start The Deploying πŸš€πŸ€˜
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact#v3
with:
name: my-app-build
- name: unzip the build folder
run: unzip my-app-build
- name: All Good To Go βœ” start Sync files to hosting
uses: SamKirkland/FTP-Deploy-Action#4.3.3
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}

PNPM Github actions flow

I just moved my project from npm and lerna to pnpm but now when using GitHub actions I get the following error
"line 1: pnpm: command not found"
can someone suggest how the .yml file should be, I've posted the current version below?
name: Lint & Unit Test
on: [pull_request]
jobs:
run-linters:
name: Run linter and Unit tests
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout#v3
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node#v3
with:
node-version: 16.18.1
- name: Portal Install Node.js dependencies
working-directory: ./portals
run: |
pnpm install
- name: Portals Lint & tests
working-directory: ./portals
run: |
cat .env.example > .env
pnpm run build:tailwind
pnpm run lint
pnpm test
- name: Services Install Node.js dependencies
working-directory: ./services
run: |
pnpm install
- name: Services Lint & tests
working-directory: ./services
run: |
pnpm run lint
pnpm test
You might need to use first the pnpm/action-setup action, in order to install pnpm.
on:
- push
- pull_request
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup#v2
with:
version: 6.0.2

Github actions how to do npm install only 1 time

I'm using GitHub actions for deploy. And i need to build vuejs app, every time when pushing. Now all working coorectly, but every time i spend action minutes for npm install.
Can i install modules 1 time, and not reinstall it after every deploy?
on: push
name: πŸš€ Deploy website on push
jobs:
web-deploy:
name: πŸŽ‰ Deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
steps:
- name: 🚚 Get latest code
uses: actions/checkout#v2.3.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install --legacy-peer-deps
- run: npm run build
- name: πŸ“‚ Sync files
uses: SamKirkland/FTP-Deploy-Action#4.0.0
with:
server: ${{ secrets.host}}
username: ${{ secrets.user}}
password: ${{ secrets.pass }}
local-dir: dist/
dangerous-clean-slate: true

gh-pages deployment issue, job fails on deploy. The directory you're trying to deploy ... doesn't exist

gh-pages deployment fails with next error: My repository failed job
Checking configuration and starting deployment… 🚦
Error: The directory you're trying to deploy named /home/runner/work/azure-flask-react/azure-flask-react/dist doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗
Deployment failed! ❌
I'm trying to deploy ReactApp at Github and besides deploy Python-Flask backend hosted at Azure and back-app has its automatically generated job yml.
But for front-app I followed this answer and manually added second job in yml because I need to provide env.variables.
My backend deployment succeeds but front-app constantly fails because of duplicated path
/home/runner/work/azure-flask-react/azure-flask-react/dist
Here is my yml and package.json but there is no any extra mentioning of that directory...
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Python app to Azure Web App - first-py-app
on:
push:
branches:
- main
workflow_dispatch:
jobs:
front-build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
- name: Build
run: |
npm --prefix front-app install
npm --prefix front-app run-script build
env:
REACT_DEV_SERVER_URL: ${{ secrets.REACT_DEV_SERVER_URL }},
REACT_DEV_FRONT_APP_URL: ${{ secrets.REACT_DEV_FRONT_APP_URL }}
- name: Deploy
uses: JamesIves/github-pages-deploy-action#releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_KEY }}
BRANCH: gh-pages
FOLDER: dist
back-build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Set up Python version
uses: actions/setup-python#v1
with:
python-version: '3.8'
- name: Build using AppService-Build
uses: azure/appservice-build#v2
with:
platform: python
platform-version: '3.8'
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy#v2
with:
app-name: 'first-py-app'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_7edcdecca83a4354a87943f94bb32fca }}
{
...
"homepage": "https://nikonov91-dev.github.io/azure-flask-react",
"scripts": {
...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
}
and my file structure
azure-proj
|-front-app (containing reactjs)
|-package.json
|-node_modules
|-src
|-app.py (python-flask application which deploys successfully)
I misunderstood the issue message, the problem was not duplicating the problem was the missed inner path passed in FOLDER in gh-pages YML settings
There was a hint in BUILD step
And one more thing: do not forget to get and add to GH your personal-access-token

Github CI/CD pipeline crashes with webpack

I'm trying to learn how CI/CD pipelines work.
I decided to use it with my portfolio page which should re-run itself on every push.
Here is my yaml config:
name: Build Bundle for Github Pages
on:
push:
branches:
- source
env:
NODE_ENV: production
PUBLIC_URL: http://crrmacarse.github.io/
GA_TRACKING_CODE: ${{ secrets.GA_TRACKING_CODE }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
with:
persist-credentials: false
- name: Build
run: |
npm install
npm run prod:pipeline
npm run sitemap
cp dist/index.html dist/404.html
cp google21029c74dc702d92.html dist/
cp robots.txt dist/
- name: Deploy
uses: JamesIves/github-pages-deploy-action#releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: source
FOLDER: dist
Here is the error:
Source code for the webpack config:
https://github.com/crrmacarse/crrmacarse.github.io/blob/source/compiler/production.pipeline.js
If the error message is cannot find module 'html-webpack-plugin', you could try, for testing, to install it.
See survivejs/webpack-book issue 100 as an example:
The solution was to run npm i html-webpack-plugin --save-dev before building with webpack
The OP has fixed the GitHub Action workflow with crrmacarse/crrmacarse.github.io commit 8a4397b
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2.0.0
- name: Use node 12
uses: actions/setup-node#v1
with:
node-version: 12
registry-url: https://registry.npmjs.org
- name: install
run: npm install
- name: lint
run: npm run sitemap
- name: build
run: npm run prod
- name: copy
run: npm run copy
Then the module html-webpack-plugin is properly installed and available, as seen in this Actions CI run.
Use npm install before build your project which installs your npm library on docker where your project will be built.
Note: Don't forget to define html-webpack-plugin on packge.json file