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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # Trigger this workflow on pushes to the main branch
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_deploy:
|
build_and_deploy:
|
||||||
runs-on: [self-hosted, linux] # Use the labels you assigned to your self-hosted runner
|
runs-on: [self-hosted, linux]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
clean: true
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Build and deploy with Docker Compose
|
- name: Create environment file
|
||||||
working-directory: /home/ubuntu/dsec_bot
|
working-directory: ${{ github.workspace }}
|
||||||
|
env:
|
||||||
|
DOT_ENV: ${{ secrets.DOT_ENV }}
|
||||||
run: |
|
run: |
|
||||||
echo "Starting Docker Compose with --build and --force-recreate..."
|
if [ -z "$DOT_ENV" ]; then
|
||||||
sudo git pull
|
echo "DOT_ENV secret is missing or empty."
|
||||||
sudo docker compose build
|
exit 1
|
||||||
sudo docker compose up -d --build
|
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."
|
echo "Deployment complete."
|
||||||
|
|
||||||
# Optional: Clean up old Docker images to save disk space
|
|
||||||
- name: Clean up old Docker images
|
- name: Clean up old Docker images
|
||||||
run: |
|
run: sudo docker image prune -f
|
||||||
echo "Cleaning up dangling Docker images..."
|
|
||||||
sudo docker image prune -f
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue