Error deploying a nextJS app on github actions - node.js

I'm trying to deploy my nextJS app on GitHub pages. I'm getting an error at the deploy stage.
My node.js.yml file contains the following:
name: Node.js CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run build
- run: npm run export
- run: touch ./out/.nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action#v4.2.5
with:
branch: gh-pages # The branch the action should deploy to.
folder: out # The folder the action should deploy.
The error code there I get while deploying my repository on another branch is the following :
remote: Permission to 0xWerz/0xwerz.github.io.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/0xWerz/0xwerz.github.io.git/': The requested URL returned error: 403
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/tpuzb7jkb
Reset branch 'github-pages-deploy-action/tpuzb7jkb'
/usr/bin/chmod -R 777 github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Error: The deploy step encountered an error: The process '/usr/bin/git' failed with exit code 128 ❌
Notice: Deployment failed! ❌

The deploy action needs write access to your repository.
Or upgrade to a newer version of the action, i.e. 4.3.3

Related

How do I deploy Angular application to Azure Web App

I have an Angular application that connects to a .NET Core web api. When I run the angular application on my machine it works without issue. When I move it to Azure, the Azure container fails and I receive the following error:
Container Crash
Application Errors that may have caused the container to crash were detected
2023-02-06T12:56:16.170621876Z 2023-02-06T12:56:16.170625276Z Error: Cannot find module './bootstrap'2023-02-06T12:56:16.170635576Z Require stack:
I modified my CICD .yml file to install the the necessary modules (see below). For some reason I cannot get the container to run. Any idea what I'm doing wrong
name: Build and deploy Node.js app to Azure
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Node.js version
uses: actions/setup-node#v1
with:
node-version: '14.x'
- name: npm install, bootstrap install and build
run: |
npm install
npm install #angular/cli
npm install bootstrap
npm run build --if-present
- name: Zip artifact for deployment
run:
zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact#v2
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact#v2
with:
name: node-app
- name: unzip artifact for deployment
run:
unzip release.zip
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy#v2
with:
app-name: '<removed for security>'
slot-name: 'Production'
publish-profile: ${{ <removed for security> }}
package: .

Azure Web application deployment successful, but does not update the web application

Previously I was having an error with the deployment of my React application on Web Service Linux on Azure. This problem was solved in the previous post I did, follow the link:
My Azure Web Application on Linux is not working. The error message on azure logs "react-scripts: not found" and github "npm ERR! code ELIFECYCLE ”.
Now I am having another problem which consists of the following:
After deploying to the Azure platform (I'm using the github option for deployment) and receiving a successful deployment notification, upon entering my github repository, I received the error
"npm ERR! Code ELIFECYCLE" (follow the link to view the entire log: https://mega.nz/folder/eth0WSiL#pGvXl2yShQfUrNELCKD3cA). Upon entering the application and testing it I noticed that the deployment really did not work.
An important point worth mentioning that in the previous problem the solution passed by #JasonPan worked, but when we tested it I still used the Azure classic
deployment center, which was removed a few days ago and after trying to use the current deployment center I came across this error.
I managed to solve the problem. I needed to do two things within my .yml file, they were:
add a CI: false and remove the npm run test
Here is the code:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Node.js version
uses: actions/setup-node#v1
with:
node-version: '14.x'
- name: npm install, build
run: |
npm install
npm run build --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact#v2
with:
name: node-app
path: .
deploy:
runs-on: ubuntu-latest
needs: build
environment:
CI: false
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
The .yml file before it was changed:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up Node.js version
uses: actions/setup-node#v1
with:
node-version: '14.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact#v2
with:
name: node-app
path: .
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

Github Actions Organisation node deployment to github pages

I have been trying to deploy a create-react-app using GitHub actions which deploys the React application to gh-pages and I get the following error when trying to deploy: -
Find out more about deployment here:
bit.ly/CRA-deploy
Cloning into '/home/runner/work/some/some/node_modules/.cache/gh-pages/github.com!***!some.git'...
remote: Repository not found.
fatal: repository 'https://github.com/***/some.git/' not found
Error: The operation was canceled.
I have the following node.js.yml
name: MasterDeployCI
on:
push:
branches:
- production
- gh-pages
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout#v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Packages
run: CI=false npm install
- name: Deploy to GH Pages
run: |
git config --global user.email ${{secrets.EMAIL}}
git config --global user.name ${{secrets.USERNAME}}
git remote set-url origin https://${{secrets.SECRET}}#github.com/${{secrets.USERNAME}}/some.git
CI=false npm run deploy
I have tried looking through the documentation and google but have been unable to find a solution.
https://github.com/Saharadigital/sahara-digital/blob/develop/.github/workflows/node.js.yml#L28
It seems secrets.USERNAME is not exists on repositories secret page. Did you checked?
https://github.com/Saharadigital/sahara-digital/runs/1311779817#step:5:4 this is also shows the same.

How to make npm run build on local machine with help of github actions?

I have a Nuxt Js application on my ubuntu server. I use my terminal to enter server and run commands on my server. I can't run command "npm run build" because my VPS has low memory and build command freezes.So I decided to make build on my PC, copy built folder to VPS and then run application.
What should I write in github actions to perform those steps?
-npm run build
-copy built folder from my machine to VPS using ssh(or password, it doesn't matter) to specific folder on VPS
What I did last time and it worked for me:
name: Deployment Setup
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
job-one:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Testing VPS connection and deploy project
uses: appleboy/ssh-action#master
with:
host: 114.12.587.105
port: 1234
username: new-user
key: ${{ secrets.PRIVATE_KEY}}
uses: appleboy/ssh-action#master
script: |
cd /home/kentforth/webapps/myapp
git pull
npm install --production
quasar build
sudo service nginx restart
EDIT:
Here is my deploy.yml file:
name: 'test my project'
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm run build
Here is What I get in github actions:
It seems github actions try to find path /home/runner/work/my project name
But I do not have such directory
How can specify I the folder on my local machine where "npm run build" command should run?

React deployment to firebase using github actions

on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout#master
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
- name: Archive Production Artifact
uses: actions/upload-artifact#master
with:
name: build
path: build
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout#master
- name: Download Artifact
uses: actions/download-artifact#master
with:
name: build
- name: Deploy to Firebase
uses: w9jds/firebase-action#master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
now this is the gtihub actions workflow it is executing build job without errors but in deployment there comes an error
this is the error image
the error its shows is Error: Specified public directory 'build' does not exist, can't deploy hosting to site landing-page-design-1 i have followed the blog from where the workflow is copied i did everything same except some of my project details which is obvious please help me out why is this error occuring and how can i fix it
You're probably unpacking artifact to root directory instead of build/.
I'm guessing article was written for download-artifact#v1 while you are using download-artifact#v2 (as that's where master points currently). Difference between both is discussed here.
I'd verify first what is going on after artifact is downloaded
- name: Display directory structure
run: ls -R
shell: bash
If files are indeed in root directory, adding path should fix that.
- name: Download Artifact
uses: actions/download-artifact#v2
with:
name: build
path: build
PS: Using actions/<name>#master is not recommended, as it can always lead to issues if same action behaves differently between versions... for example actions/download-artifact ;)
You can also try to use firebase-publish-react to simplify your workflow file
This particular action plugin takes care of building the application internally and also can reuse the build directory from previous steps.
- name: Deploy to Firebase
uses: mohammed-atif/firebase-publish-react#v1.0
with:
firebase-token: ${{ secrets.FIREBASE_TOKEN }}

Resources