-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from setoelkahfi/feature/v1.1
v1.1
- Loading branch information
Showing
4 changed files
with
159 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Seto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,58 @@ | ||
# gapush-to-deploy | ||
# garust-debian | ||
|
||
GitHub Action to deploy main branch to production a la Heroku. | ||
GitHub Action to running Rust binary on Debian Bulls Eye using SSH `rsync`. | ||
|
||
## Supported runner | ||
|
||
`ubuntu-20.04` | ||
|
||
[What is my Debian in my Ubuntu?](https://askubuntu.com/a/445496/513710). | ||
|
||
## Input | ||
|
||
```yaml | ||
working-directory: | ||
description: "Working directory for the build." | ||
required: true | ||
binary-name: | ||
description: "Name of the binary to run. Usually the [[bin]] value in the Cargo.toml." | ||
required: true | ||
ssh-user: | ||
description: "SSH user." | ||
required: true | ||
ssh-host: | ||
description: "SSH host." | ||
required: true | ||
ssh-private-key: | ||
description: "SSH private key." | ||
required: true | ||
ssh-known-hosts: | ||
description: "SSH known hosts." | ||
required: true | ||
``` | ||
## Example | ||
```yaml | ||
name: "Build and release" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: setoelkahfi/garust-debian@v1 | ||
with: Install Rust stable | ||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | ||
ssh-user: ${{ secrets.SSH_USER }} | ||
ssh-host: ${{ secrets.SSH_HOST }} | ||
project-directory: ${{ secrets.PROJECT_DIRECTORY }} | ||
project-name: ${{ secrets.PROJECT_NAME }} | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
echo "------------------------ STARTING DEPLOYMENT ------------------------" | ||
|
||
# Check if the first argument is a directory | ||
if [ ! -d "$1" ] | ||
then | ||
echo "😩 $1 is not a directory." | ||
echo "🛑 Deployment failed." | ||
exit 1 | ||
fi | ||
|
||
# Change to working directory | ||
cd $1 | ||
|
||
# Check if process is running | ||
|
||
# Check if the second argument is a process | ||
if [ -z "$2" ] | ||
then | ||
echo "😩 No process name provided." | ||
echo "🛑 Deployment failed." | ||
exit 1 | ||
fi | ||
process_name=$2 | ||
|
||
# Check if binary exists | ||
if [ ! -f "$process_name" ] | ||
then | ||
echo "😩 $process_name does not exist." | ||
echo "🛑 Deployment failed." | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Arguments are valid." | ||
|
||
# Check if process is running | ||
echo "🔍 Looking for $process_name process." | ||
PID=$(pidof $process_name) | ||
|
||
echo "🤨 Killing or not killing $process_name." | ||
|
||
if [ ! -z "$PID" ] | ||
then | ||
echo "✅ $process_name is running as $PID." | ||
echo "⏳ Killing it." | ||
kill -9 $PID | ||
echo "✅ Killed $process_name." | ||
else | ||
echo "$process_name is not running." | ||
echo "No killing needed." | ||
fi | ||
|
||
echo "🚀 Starting $process_name." | ||
|
||
./$process_name > /dev/null 2>&1 & | ||
|
||
echo "------------------------ DEPLOYMENT COMPLETED ------------------------" | ||
|
||
exit 0 |