mirror of
https://github.com/dsec-hub/dsec-discord-bot.git
synced 2026-09-22 07:44:26 +00:00
updated github actions
This commit is contained in:
parent
941c02d2f2
commit
2e3da35f91
1 changed files with 30 additions and 21 deletions
33
.github/workflows/deploy.yml
vendored
33
.github/workflows/deploy.yml
vendored
|
|
@ -3,28 +3,37 @@ name: Docker Compose Deploy
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Trigger this workflow on pushes to the main branch
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_and_deploy:
|
||||
runs-on: [self-hosted, linux] # Use the labels you assigned to your self-hosted runner
|
||||
runs-on: [self-hosted, linux]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
clean: true
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Build and deploy with Docker Compose
|
||||
working-directory: /home/ubuntu/dsec_bot
|
||||
- name: Create environment file
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
DOT_ENV: ${{ secrets.DOT_ENV }}
|
||||
run: |
|
||||
echo "Starting Docker Compose with --build and --force-recreate..."
|
||||
sudo git pull
|
||||
sudo docker compose build
|
||||
sudo docker compose up -d --build
|
||||
if [ -z "$DOT_ENV" ]; then
|
||||
echo "DOT_ENV secret is missing or empty."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask 077
|
||||
printf '%s\n' "$DOT_ENV" > .env
|
||||
|
||||
- name: Build and deploy
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
sudo docker compose up -d --build --force-recreate
|
||||
echo "Deployment complete."
|
||||
|
||||
# Optional: Clean up old Docker images to save disk space
|
||||
- name: Clean up old Docker images
|
||||
run: |
|
||||
echo "Cleaning up dangling Docker images..."
|
||||
sudo docker image prune -f
|
||||
run: sudo docker image prune -f
|
||||
|
|
|
|||
Loading…
Reference in a new issue