I want to deploy a website stored on github to a shared server from OVH. So, basically, after each push I would like the new code to auto-deploy on my server.
I read this article (in french, sorry). To sum it up, it explains how to do it with BitBucket. They provide a php file to put on your server. Then, you make BitBucket send a POST request on that file, and it's over. Here is the code of that php file.
My only trouble is that I know nothing about php and that file is made for BitBucket and not GitHub. But I think it should be easy to make it work with GitHub. The only line to change should be that one :
$url = "https://api.bitbucket.org/1.0/repositories".$uri."raw/".$node."/".$file->file;
Instead of BitBucket I should adapt for GitHub... But I have no idea of what I should write instead...
Could anyone help me with that ?
Related
I am developing a laravel application and have a test server setup to show the demo to client. How i get the code in server is I push the code to github and login to server and pull the code there and run.
Is there an automated way of doing this? I looked at continuous integration/delivery and it seemed to be dealing with testing the code?
You can make it by using webhook
To get git pull to run on the server every time there is a commit, can be achieved by using Webhooks.
On GitLab go to Settings -> Integrations
Enter a url to your server and a file to handle the webhook for this tutorial I will create a file called gitlab.php to the url will be
http://example.com/gitlab.php
Enter your url ensure push events is tickets and click Add Webook.
Now head over to your server and create a php file on the server.
touch gitlab.php (you can name it anything but it much match the webhook on GitLab)
As the file created won’t have the right permissions change it with chmod
chmod 644 gitlab.php
Now edit the file with vim:
vi gitlab.php
Press i to go into edit mode
Type:
git pull
Then press escape to go into read mode then save and exit by pressing : then type wq and enter.
By using backticks in the file the server will treat the file as a bash script.
Alternatively, you can use system_exec(‘git pull’)
Now make a change on GitLab and the change will be pushed to your server automatically.
Using rsync
1) You could rsync the code directly from your instance to the customers server:/path/
Example:
rsync -avz yourwebfolder/ user#customerserverip:/var/www/
Using CI/CD
2) You can also push to Github or Gitlab and have a CI/CD which may run tests, and if they pass, to push directly to the customer's server, (for which you would need to setup ssh keys between the git build and the customer's server)
Testing of the code is always optional but also always preferable. So you can do a CI/CD without any testing..
How To CI/CD
If your repository is on Github go to it and then click on Actions, and there you can setup workflows.. There are tutorials online on how to set it up, here's one exampe tutorial.
Gitlab has similar CI/CD section, where you can create a .gitlab-ci.yml file in the root of the project, and add the instructions there.
Create an SSH key in the server and add that the public key to github. Once you have done that, you do not need to login to push or pull.
Creating public and private key
http://lunar.lyris.com/help/lm_help/12.0/Content/generating_public_and_private_keys.html
Adding keys to github
https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account
I've been spending few days trying to figure out how to set aws s3 as external storage for Resourcespace. and i've been getting more confused with the this app.
I'm using the opensource version and trying to customize it to my needs.
I've been through the web app's lengthy documentation but couldn't find anything about setting storage (like other web apps out there) However, I found a feature called syncdir where it sets an alternative external storage (for backup) but not as an external storage, as from the documentation, it doesent seem to have a direct method to specify storage/integrate s3 with it.
I've tried the following:
I've tried using aws s3 integration and how to integrate to any php website, by changing storing directory of 'storagedir' and directory of 'syncdir' in config.default file (i added the require s3 autoload file and added aws keys in config file), but it's not working, site is still storing locally
Note: I've integrated aws s3 before with Laravel 5.7 & Codeigniter 3 frameworks successfully.
I tried adding the require aws-autoload into the file where uploading functions is, and tried to look for the code responsible to upload, but code seems confusing to me where the upload functionality is (its not a php funtion where $_FILES receives your upload.
Changed place of require aws-autoload into include/general.php, but no luck.
Followed up with some forums on the matter like:
using external storage
Amazon S3 integration
I'm assuming that using the config file (to store AWS credentials and storage set to s3 bucket url), i include the aws-autoload in general/upload file, and it would automatically understand where it should upload, but no error or bug is reporting to address it.
But most of what i found is related to the paid version of the DAM system where it seems to be already set up on amazon.
Please advise, Any help is appreciated.
I'm using Wamp on Winddows 10 PC btw
Check this discussion out, it might help you :
https://groups.google.com/forum/#!topic/resourcespace/JT833klfwjc
It look like it is still a work in progress, so you may see the WIP code,
You will find links to code in the mentioned link.
New to AWS. Need help in regards to editing a php file of an application hosted on ex2.
I'm able to connect to my ex2 via Putty and am able to locate and edit the php file. But when I refresh the browser cannot see my changes.
It's an Linux Ami.
Any help much appreciated.
Thanks Fabian.
The Php file is just one from the application not any configuration file. It's got a harmless form element.
However I'm not sure of any framework being used, as this application was developed by another developer who is not with the business.
As I'm trying to get a hang of the app, I tried and edited a text string within the php/htm file.
Hope this helps.
I have just created a simple REST Api following this small video using Slim Framework 3.x. I was just getting started and I followed the instructions in the video and created a simple route like this
$app->get('/', function($request, $response)
{
return 'Home';
});
This works on localserver (XAMP) when I open the link `
localserver/project_name/public/
` I get "Home" returned on the page.
After that I simply Zipped the project folder and uploaded it to my Web Hosting, htdocs folder. I extracted the zipped project, which included the "composer.phar" and "vendor" folder. I try the same thing again, i.e., I run the url
www.mysite.com/project_name/public/
All I've done is change "localserver" with www.mysite.com but the browser tells me that my domain
is currently unable to handle this request.
I know this might be something very obvious but I am a novice in php and REST Api's. So any help is appreciated. Also some things I think might matter are, The web hosting that I am using is Plesk based. I have a mysql database Running on the hosting and simple php files run when run individually. For example if I run simple call a test.php file with some database query in it and some echo, it will run successfully. Even if you can point me in the right direction, I would appreciate it. Oh, and I don't have access to php.ini on the hosting. I was only provided with one login that lets me login to the hosting and I can see htdocs folder among some others. I have attached an
image of the view I get after logging in, to give you more perspective of the type of hosting I have. I am hosting a website in the httpdocs directory as well. ASP.NET developed
I just need some direction as to what I need to do to be able to publish my REST api to my hosting and be able to access it through this android app that I am building. What do i need to do on my server? What settings to change to make the api work?
We have the following setup - remote repository with gitlab gui.
Our webserver is located on another server and we have ssh access to it. We also have local copies of our dev site, our git setup right now just push to the repo in gitlab.
My goal is to automate the process and on every push to gitlab repo to update the server dir with latest changes.
I saw that for this purpose we should use webhooks or deploy keys. I want to avoid using cron job.
I created a bash script which performs git pull after certain php file is accessed.
However when I placed the url to this php file in webhook section in gitlab, nothing happened.
If I access the file manually by typing url in address bar it works ok.
When I try to test the hook I get 500 error and timeout.
Any recommendations how to improve this process or where Im going wrong ?
The webhook does not just sends a get request to the provided URL, it also sends its data as JSON in raw data.
Can your script handle that?
Have a look at gitlab-webhook-push.php
The actual issue was that gitlab was not able to access our domain and was leading to timeouts, of course sys admins decided to restrict the access from external sources without notifying. Also it is good to mention that JSON raw data can be used for more complex solutions which is pretty nice.