fix(infra): add caddy container and update github actions (#10) #10
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
name: Local Deployment | |
on: | |
push: | |
branches: main | |
jobs: | |
deploy: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Load dotenv from secret for Grafana Configuration | |
run: | | |
cat <<EOF > .env | |
# Sensitive configurations from GitHub Secrets | |
GF_SMTP_HOST = ${{ secrets.SMTP_HOST }} | |
GF_SMTP_USER = ${{ secrets.SMTP_USER }} | |
GF_SMTP_PASSWORD = ${{ secrets.SMTP_PASSWORD }} | |
GF_SMTP_FROM_ADDRESS = ${{ secrets.FROM_ADDRESS }} | |
EOF | |
- name: Check if containers are running | |
id: check-container | |
run: | | |
{ | |
echo 'stdout<<EOF' | |
docker compose --profile log ps -q | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
- name: Initialize containers | |
if: steps.check-container.outputs.stdout == '' | |
run: | | |
docker compose --profile caddy up -d --no-recreate | |
docker compose --profile log up -d --no-recreate | |
- name: Run Docker Compose | |
run: | | |
docker compose --profile log up -d | |
- name: Copy Caddyfile into Caddy Container | |
run: | | |
docker cp ./Caddyfile caddy:/etc/caddy/Caddyfile | |
- name: Gracefully reload Caddy | |
run: | | |
docker exec -w /etc/caddy caddy caddy reload | |
- name: Remove unused docker storages | |
run: docker system prune -a -f --volumes |