I'm working on a WP project on my local machine with Vagrant virtualization.
I created a script in my package.json so i can easily merge my branches, push to Gitlab and pull the git repo on my staging environment via NPM or Yarn
I added my staging server's public key to the deployment keys in my gitlab project, tested it and it works.
my package.json content:
{
"name": "axis",
"version": "1.0.0",
"description": "A development environment based on Vagrant, optimized for WP development",
"devDependencies": {
"autoprefixer": "latest",
"node-sass": "latest",
"watch": "latest",
"onchange": "latest",
"postcss-cli": "latest"
},
"scripts": {
"build": "node-sass www/wp-content/themes/axis/sass/screen.scss www/wp-content/themes/axis/stylesheets/screen.css && yarn run autopre",
"autopre": "postcss --use autoprefixer www/wp-content/themes/axis/stylesheets/*.css -d www/wp-content/themes/axis/stylesheets/",
"watch": "yarn run watch:css",
"watch:css" : "onchange 'www/wp-content/themes/axis/sass/**/*' -- yarn run build",
"gitmerge": "git checkout staging && git merge dev && git checkout dev && git push --all origin && ssh ***#***.nl \" cd www/axis.nl && echo 'it works till here' && git pull origin staging;\""
}
}
When I run the script i get the following error:
Permission denied (publickey).
fatal: Could not read from remote repository.
And here follows the weird part:
When I repeat the command step by step I don't get the error and it successfully pulls the repo.
If I Google the error I get thousands of hits but not for this specific situation.
anyone with a similar situation?
Related
I've just discovered Github workflows and I've been trying to create two for a private C++ repository of mine, which contains a small C++ library.
I've succeeded in creating one that runs on Ubuntu (i.e., it runs and completes successfully), but the other that runs on Windows (almost an exact copy of that one that runs on Ubuntu) fails due to a missing C library.
This is the .yml file of the workflow that runs on Windows:
name: CMake
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
# the directory of the library's source code (and which contains the CMakeLists.txt)
LAL_DIR: D:\a\linear-arrangement-library\linear-arrangement-library/lal
# directories of the different builds
REL_DIR: ${{github.workspace}}/windows-build-release
DEB_DIR: ${{github.workspace}}/windows-build-debug
jobs:
windows_build:
runs-on: windows-2019
steps:
- uses: actions/checkout#v2
- name: Configure CMake on Windows
run: cmake -G "MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ${{env.LAL_DIR}} -B ${{env.REL_DIR}} -DCMAKE_BUILD_TYPE=Release ;
cmake -G "MSYS Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ${{env.LAL_DIR}} -B ${{env.DEB_DIR}} -DCMAKE_BUILD_TYPE=Debug
- name: Build on Windows
run: cmake --build ${{env.REL_DIR}} --config Release -j4 ;
cmake --build ${{env.DEB_DIR}} --config Debug -j4
I'm new on this, so I don't know if I applied the "best practices" (if there are any).
The error I get is the following:
In file included from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_rooted_trees.hpp:50,
from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_free_trees.hpp:50,
from D:/a/linear-arrangement-library/linear-arrangement-library/lal/generate/rand_ulab_free_trees.cpp:42:
D:/a/linear-arrangement-library/linear-arrangement-library/lal/numeric/integer.hpp:45:10: fatal error: gmp.h: No such file or directory
#include <gmp.h>
^~~~~~~
compilation terminated.
The error is telling me that g++ can't find the file gmp.h. The workflow running on Ubuntu, however, does not fail.
I guess that the system executing Ubuntu's workflow simply has the gmp library installed, whereas the one executing Window's workflow doesn't. How can I resolve this? (if it is actually possible, that is)
Thank you very much.
Hi I wonder if this scenario is even possible.
I am using openapi-generator with typescript-axios generator option and want to know if it can be automated as below.
This is my initial thought.
Create a project and add script to generate code using openapi-generator and compile.
ex) "build": "openapi-generator-cli generate -g typescript-axios -o src -i https://myapi.com/swagger.json
&& tsc"
Upload to github and add a webhook so it gets notifications when our api project gets PR or commit.
Once this webhook gets notification, Github action triggers and generates new client sdk and compiled lib with script at no.1
I tired this with below work flow but published package doesn't contain generated code.
Any help would be appreciated.
name: Node.js Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 12
- run: npm ci
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run-script build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
and my package.json
{
"name": "my-api-client",
"version": "1.0.0",
"description": "Openapi generated typescript-axios client",
"main": "index.js",
"scripts": {
"test": "echo \\\"Error: no test specified\\\" && exit 1",
"build": "openapi-generator-cli generate -g typescript-axios -o src -i https://myapi.com/swagger.json --type-mappings=DateTime=Date && tsc"
},
"keywords": [
"typescript-axios",
"client"
],
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"typescript": "^3.8.3"
},
"devDependencies": {
"#openapitools/openapi-generator-cli": "^2.0.3",
"#types/node": "^13.9.0"
}
}```
Thank you
I accidently add src and lib folder and that was the reason my published package didn't contain those folders. After fixing .gitignore everything works fine.
So basically, my project will only contain package.json and whenever I create a release tag, it will trigger above Github workflow and publish a new openapi-generated client sdk to npm.
I have googled and searched and cannot find an answer to this. I have my page at github and it just returns a hyperlink with the readme. Here is the current repo: https://github.com/brianmsantos/brianmsantos.github.io.
Create an index.html and add your content there. See https://pages.github.com/
1 create package.json and add
{
"homepage": "https://name.github.io/appname",
…
}
2.Use the terminal and install gh pages using command:
npm install --save gh-pages
3.Add this to your scripts in package.json
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
…
}
make deploy using npm run deploy in commandline
5 in your repository settings set the branch to gh-pages branch and save
So, I have a library haste-mapper (link to Github - I would like some opinions on it). It uses gulp, babel-core and a few other npm packages to build itself so as to have valid JavaScript instead of Flow into the build/ directory. I added that as a postinstall hook script in package.json:
"postinstall": "gulp build"
It works, the script starts running but it does not meet the required dependencies in the host package. I have gulp and babel-core as devDependencies and it seems not to install them. Adding them to dependencies seems semantically wrong. I tried adding them to peerDependencies, but instead of installing what's missing, it just complains about it.
How should I go about this?
P.S. Here is the package.json
If you want to use something in a postinstall hook, it needs to be a dependency.
However, you're doing it wrong. You shouldn't be transpiling your code after the install. Instead, you should transpile your code before you publish the package.
To do that, you will need to rename your script to prepublish so that it is run when you run npm publish. List gulp, babel, etc. as devDependencies. Add an .npmignore file in the root of your project, containing:
/src/
The .npmignore file works just like a .gitignore. You don't want your src/ directory included in the published package, only build/. Make sure .npmignore is committed to git. If you don't have an .npmignore, npm will use the .gitignore file. This isn't what you want, since build/ is ignored for version control, but should be included in the npm package.
When you run npm publish, npm will run your prepublish hook before bundling your package for the registry. Then when someone npm installs your package, they will get the build/ folder, but not src/. Just what you want!
I started to leave a comment on RyanZim's answer because his technique is correct. However, I wanted to give a slightly different approach. Our company maintains a lot of open source projects and this is how we would advise you.
Keep developing your project like you normally would. Your .gitignore file should be ignoring your dist directory (/build in your case).
When you are ready to deploy, you want to build your code, bump your version number inside package.json, tag the changes, and push the built code to both github and npm.
The main idea is that we want to keep a copy of our built code in github along with a "tag" for that version. This allows us to see exactly what was pushed to npm for any particular version. The built code is not part of the master branch but exists only under a tag (which is sort of like a branch). When a user reports a bug and he's using version x.x.x, you can checkout that exact version and start debugging. When you fix the bug, you release a new "patch" and your user will get the changes the next time he runs npm install or npm update.
We have created a set of npm scripts to do most of this for us. Here is what we use (this goes in your package.json):
"scripts": {
"build": "node build.js",
"preversion": "npm run build",
"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/",
"postversion": "git push --tags && git checkout master && git branch -D release && git push",
"release:pre": "npm version prerelease && npm publish",
"release:patch": "npm version patch && npm publish",
"release:minor": "npm version minor && npm publish",
"release:major": "npm version major && npm publish"
}
I know that may look confusing so let me explain. Whenever we are ready to release new code, we run one of the release: commands. For example, when we run npm run release:minor, here is the list of commands which are run in order. I have annotated it so you can see what happens:
node build.js ## run the build code - you will want to run gulp instead
npm version minor ## bumps the version number in package.json and creates a new git tag
git commit -am "Update dist for release" ## commit the package.json change to git (with new version number) - we will push it at the end
git checkout -b release ## create a temporary "release" branch
git add -f dist/ ## force add our dist/ directory - you will want to add your build/ directory instead
npm publish ## push the code to npm
git push --tags ## push the built code and tags to github
git checkout master ## go back to the master branch
git branch -D release ## delete the temporary "release" branch
git push ## push the updated package.json to github
If you have any questions, please ask. You might want to do things in a slightly different order as your situation is a little different. Please feel free to ask questions. This code works really well on dozens of projects - we release new code multiple times a day.
We use Mercurial (hg) for source control with a central repository (each developer has their own local as well). I am trying to set up a hook in the central repo such that it kicks off a Jenkins CI build.
The hook appears in the hgrc file as:
[hooks]
incoming.jenkins = java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects"
[ui]
verbose = True
debug = True
Now, I have tested the command invoked from the hook on the command-line of the machine that hosts the central repository and it works as expected.
However, when I trigger the hook with a push to the central repository, I see the following output:
% hg --repository D:\dev\hg\******\source push W:\Repository\*********
pushing to W:\Repository\**********
searching for changes
adding changesets
add changeset 62784303122b
adding manifests
adding file changes
adding ****/CMakeLists.txt revisions
added 1 changesets with 1 changes to 1 files
updating the branch cache
running hook incoming.jenkins: java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects"
warning: incoming.jenkins hook exited with status 1
[command completed successfully Fri Jul 26 15:24:58 2013]
The server in question is a Windows machine. Any ideas what could be going wrong or how to get more details on the error?
UPDATE:
So I modified the hook to get more info:
incoming.jenkins = java -jar C:/buildServerJar/jenkins-cli.jar -s http://ctc-jenkins:8080/ -i C:/buildServerJar/id_rsa build "All Working Projects" > hg_output.log 2> hg_errors.log
And it says it is unable to locate the jarfile, which is clearly in the location indicated. Makes me wonder if it is a permissions issue. Does anyone know what user account Mercurial runs its hooks under?
Error: Unable to access jarfile C:/buildServerJar/jenkins-cli.jar