Skip to content

Commit c6f3fae

Browse files
committed
First Commit
1 parent b83197a commit c6f3fae

5 files changed

Lines changed: 238 additions & 0 deletions

File tree

LICENSE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Proprietary License
2+
3+
This repository and the code within are proprietary and are licensed under the following terms:
4+
5+
1. **License Grant**: Upon payment of the subscription fee, you are granted a non-exclusive, non-transferable, revocable license to use the code contained in this repository for the duration of your subscription.
6+
7+
2. **Restrictions**: You may not:
8+
- Redistribute, sublicense, or otherwise transfer the code or any portion thereof.
9+
- Use the code for any unlawful purpose or in violation of any local, state, federal, or international law.
10+
11+
3. **Termination**: This license is effective until terminated. Your rights under this license will terminate automatically without notice from the author if you fail to comply with any term(s) of this license.
12+
13+
4. **Disclaimer of Warranty**: The code is provided "as is" without warranty of any kind, either express or implied.
14+
15+
5. **Limitation of Liability**: In no event shall the author be liable for any special, incidental, indirect, or consequential damages whatsoever arising out of the use of or inability to use the code.
16+
17+
For more details, please contact contact@deployrepository.com
18+
19+
## Student Tier
20+
21+
We offer a special discounted rate for students to support learning and education. If you are a student, you can subscribe to our Student Tier for $1 a month. This tier grants you access to DeployRepository/zero-downtime-deployment with unlimited projects, deployments, and team members.
22+
23+
To qualify for the Student Tier, please ensure you provide valid student credentials during the subscription process.

README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Zero downtime deployment
2+
3+
## Overview
4+
This GitHub Action helps you deploy your project to a remote server with zero downtime, ensuring that your application remains available during deployments.
5+
6+
## Features
7+
- **Zero Downtime Deployment**: Ensure uninterrupted service during deployments.
8+
- **Multi-Technology Support**: Currently supporting Laravel, with more technologies being added.
9+
- **Easy Integration**: Simple setup and integration into your existing workflow.
10+
- **Flexible Deployment**: Suitable for projects of all sizes, from personal projects to enterprise applications.
11+
- **Custom Scripts**: Run custom scripts before and after key deployment steps.
12+
- **Secure**: Uses GitHub Secrets for sensitive data like server credentials and GitHub tokens.
13+
- **Environment File Sync**: Sync environment variables with the remote server.
14+
15+
## Example Usage
16+
17+
Here's an example workflow configuration that uses the `DeployRepository/zero-downtime-deployment@v1.0.0` action:
18+
19+
> [!IMPORTANT]
20+
> You need to add the following secrets to your repository:
21+
22+
- **GH_TOKEN**: You'll need to provide the action with a **Personal Access Token (PAT)**, Permission we need is `repo`
23+
[How To create](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)
24+
- **REMOTE_HOST**: the host of the server
25+
- **REMOTE_USER**: the username of the server
26+
- **REMOTE_PASSWORD**: the password of the server
27+
- **REMOTE_PORT**: the port of the server
28+
- **ENV_FILE**: the content of the environment file to sync with `.env`
29+
30+
### Notes
31+
- The `target` input should be the path to the directory where the project will be deployed on the server (ex: /home/www/test.com).
32+
- The `target/current/public` directory should be the root of the domain.
33+
- Use the `${{ github.sha }}` variable to pass the commit SHA to the `sha` input.
34+
35+
### Start Use with Laravel
36+
To use this action in your workflow, you need to add the following step in your GitHub Actions workflow file (`.github/workflows/your-workflow.yml`):
37+
38+
```yaml
39+
name: deploy to server
40+
41+
concurrency:
42+
group: production
43+
cancel-in-progress: true
44+
45+
on:
46+
release:
47+
types: [released]
48+
49+
jobs:
50+
deployment:
51+
runs-on: ubuntu-latest
52+
environment: production
53+
54+
steps:
55+
- name: Deploy Laravel project
56+
uses: DeployRepository/zero-downtime-deployment@v1.0.0
57+
with:
58+
host: ${{ secrets.REMOTE_HOST }}
59+
username: ${{ secrets.REMOTE_USER }}
60+
password: ${{ secrets.REMOTE_PASSWORD }}
61+
port: ${{ secrets.REMOTE_PORT }}
62+
target: '/home/www/test.com' # Path to the directory where the project will be deployed
63+
sha: ${{ github.sha }}
64+
github_token: ${{ secrets.GH_TOKEN }}
65+
env_file: ${{ secrets.ENV_FILE }}
66+
# run_script_before_check_folders: ls -la
67+
# run_script_after_check_folders: ls -la
68+
# run_script_before_download: ls -la
69+
run_script_after_download: |
70+
cd $THIS_RELEASE_PATH
71+
composer install --prefer-dist
72+
php artisan migrate --force
73+
php artisan storage:link
74+
# run_script_before_activate: ls -la
75+
run_script_after_activate: |
76+
cd $ACTIVE_RELEASE_PATH
77+
php artisan optimize
78+
```
79+
For test, go and create your first release, you can see process of deploy in tab of actions in your repo
80+
81+
## Support
82+
If you need help or have any questions, feel free to reach out to me at [Discussion](https://github.com/DeployRepository/zero-downtime-deployment/discussions).
83+
84+
## This GitHub Action Is Sponsorware 💰💰💰
85+
Originally, this github action was only available to my sponsors on GitHub Sponsors until I reached 100 sponsors.
86+
87+
<!-- Now that we've reached the goal, the github action is fully open source. -->
88+
89+
Enjoy, and thanks for the support! ❤️ [Become a sponsor](https://github.com/sponsors/DeployRepository)
90+
91+
Learn more about Sponsorware at github.com/sponsorware/docs 💰.
92+
93+
## Custom Scripts
94+
You can provide custom scripts to run at various stages of the deployment. Below are the supported stages where you can run your scripts:
95+
96+
- **Before Checking Folders**: `run_script_before_check_folders`
97+
- **After Checking Folders**: `run_script_after_check_folders`
98+
- **Before Downloading Release**: `run_script_before_download`
99+
- **After Downloading Release**: `run_script_after_download`
100+
- **Before Activating Release**: `run_script_before_activate`
101+
- **After Activating Release**: `run_script_after_activate`
102+
103+
## Troubleshooting
104+
If you encounter issues, check the GitHub Actions logs for detailed error messages. Ensure that:
105+
- SSH credentials are correct.
106+
- The target directory on the remote server has the necessary permissions.
107+
- The specified Git commit SHA exists in your repository.
108+
109+
## Inputs
110+
111+
| Name | Description | Required | Default |
112+
|------------------------------|------------------------------------------------|----------|---------|
113+
| `host` | Remote server host | Yes | |
114+
| `username` | Remote server username | Yes | |
115+
| `password` | Remote server password | Yes | |
116+
| `port` | Remote server port | Yes | `22` |
117+
| `target` | Remote server target path | Yes | |
118+
| `sha` | Git commit SHA to deploy (use `${{ github.sha }}`) | Yes | |
119+
| `github_token` | GitHub token | Yes | |
120+
| `env_file` | Content of the environment file to sync with `.env` | No | |
121+
| `run_script_before_check_folders` | Script to run before checking folders | No | `false` |
122+
| `run_script_after_check_folders` | Script to run after checking folders | No | `false` |
123+
| `run_script_before_download` | Script to run before downloading release | No | `false` |
124+
| `run_script_after_download` | Script to run after downloading release | No | `false` |
125+
| `run_script_before_activate` | Script to run before activating release | No | `false` |
126+
| `run_script_after_activate` | Script to run after activating release | No | `false` |
127+
128+
## Security
129+
Ensure that sensitive data such as server credentials and GitHub tokens are stored securely using GitHub Secrets.
130+
131+
## License
132+
133+
This repository and the code within are proprietary. Access is granted to sponsors only. Please see the [LICENSE](LICENSE.md) file for more information.
134+
135+
## Contribution and Issues
136+
If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/DeployRepository/zero-downtime-deployment).
137+
138+
This documentation should provide a clear and comprehensive guide for users to get started with your GitHub Action.

action.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Zero Downtime Deployment'
2+
description: 'Deploy project to server by ssh with zero downtime deployment.'
3+
4+
inputs:
5+
host:
6+
description: 'Remote server host'
7+
required: true
8+
username:
9+
description: 'Remote server username'
10+
required: true
11+
port:
12+
description: 'Remote server port'
13+
required: true
14+
password:
15+
description: 'Remote server password'
16+
required: true
17+
target:
18+
description: 'Remote server target path'
19+
required: true
20+
sha:
21+
description: 'Git commit sha need to deploy (github.sha)'
22+
required: true
23+
github_token:
24+
description: 'Github token'
25+
required: true
26+
env_file:
27+
description: 'Environment file content to sync with .env file'
28+
required: false
29+
30+
run_script_before_check_folders:
31+
description: 'Run script before checking folders'
32+
required: false
33+
default: 'false'
34+
run_script_after_check_folders:
35+
description: 'Run script after checking folders'
36+
required: false
37+
default: 'false'
38+
run_script_before_download:
39+
description: 'Run script before download release'
40+
required: false
41+
default: 'false'
42+
run_script_after_download:
43+
description: 'Run script after download release'
44+
required: false
45+
default: 'false'
46+
run_script_before_activate:
47+
description: 'Run script before activate release'
48+
required: false
49+
default: 'false'
50+
run_script_after_activate:
51+
description: 'Run script after activate release'
52+
required: false
53+
default: 'false'
54+
55+
runs:
56+
using: 'node20'
57+
main: 'index.js'
58+
59+
branding:
60+
icon: "upload-cloud"
61+
color: "black"

index.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pagent.exe

49.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)