-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(devops): add deployment workflow
- Loading branch information
1 parent
12c2e16
commit 9f9c0c4
Showing
5 changed files
with
62 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
name: Deploy Bot | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
dump-env: | ||
runs-on: ubuntu-latest | ||
environment: PROD | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Write Secret to .env File | ||
env: | ||
ENV_FILE: ${{ secrets.ENV_FILE }} | ||
run: | | ||
echo "$ENV_FILE" > .env | ||
echo ".env file created with the contents of ENV_FILE secret" | ||
- name: Set up SSH for Deployment | ||
env: | ||
SSH_USER: ${{ secrets.SSH_USER }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
run: | | ||
apt-get update && apt-get install -y sshpass | ||
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST" "mkdir -p ~/ovisbot" | ||
- name: Upload Code to Server | ||
env: | ||
SSH_USER: ${{ secrets.SSH_USER }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
run: | | ||
sshpass -p "$SSH_PASSWORD" rsync -avz --exclude '.git' ./ "$SSH_USER@$SSH_HOST:~/ovisbot" | ||
- name: Deploy Application | ||
env: | ||
SSH_USER: ${{ secrets.SSH_USER }} | ||
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
run: | | ||
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST" << 'EOF' | ||
cd ~/ovisbot | ||
if [ -f docker-compose.yml ]; then | ||
docker compose -f docker-compose.yml -f docker-compose.prod.yml down || true | ||
docker compose -f docker-compose.yml -f docker-compose.prod.yml pull | ||
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d | ||
else | ||
echo "docker-compose.yml not found in the repository!" | ||
exit 1 | ||
fi | ||
EOF |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
services: | ||
bot: | ||
build: | ||
dockerfile: Dockerfile-prod | ||
image: ghcr.io/cybermouflons/ovisbot:latest | ||
volumes: [] |