Skip to content

1aWebmarketing/github-laravel-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Deploy a laravel app through github to a managed server using github actions

Prerequisites

We assume, that you already manage your laravel app in a github repository. When you just start with github we recommend using the GitHub Desktop client.

Prepare SSH Keys

As github builds your app and transfers it to your managed server via ssh, you will need a private SSH Key for your github and need to add the public key to your server-providers ssh account.

Add a new SSH Key Pair with the following command:

ssh-keygen -m PEM -t rsa -b 4096

Give it an absolute path with a name and 2 files should be generated. A sshkeyname file and sshkeyname.public file.

Please Note: You should not set a Passphrase (keep it empty)

Setting up the variables

We will need a few github repository variables for this to work: In your repository go to Settings Secrets and variables Actions and set the following variables and secrets:

Type Name Value
Variable SSH_HOST Hostname or IP of your server
Variable SSH_USER SSH username
Variable SSH_PATH Path to the folder, where your compiled laravel app should be copied /www/htdocs/w01f4....
Secret SSH_PRIVATE_KEY Complete content of your private key file, usually starts with something like -----BEGIN RSA PRIVATE KEY-----

Note that you cannot see/read/view the Secret Variables after you set them. Keep a copy of your keys when you want to use them for other projects.

Adding workflow to github

You can use the online repository viewer to add the workflow or add it by committing the workflow file .github/workflows/nameyourworkflow.yml

Thats it

Check, if your workflow.yml is visible in your repository after committing. It should also be visible in the Actions Tab of your repository.

References

Recommended .gitignore for Laravel

**/.DS_Store
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.example
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode

About

Deploy a Laravel App with github actions to a managed server via remote SSH

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published