feat(infra): add grafana agent code (#61) #46
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 }} | |
MINIO_ROOT_USER = ${{ secrets.MINIO_ROOT_USER }} | |
MINIO_ROOT_PASSWORD = ${{ secrets.MINIO_ROOT_PASSWORD }} | |
MS_WEBHOOK_URL = ${{ secrets.MS_WEBHOOK_URL }} | |
GH_CLIENT_ID = ${{ secrets.GH_CLIENT_ID }} | |
GH_CLIENT_SECRET = ${{ secrets.GH_CLIENT_SECRET }} | |
EOF | |
- name: Check if caddy container is running | |
id: check-caddy-container | |
run: | | |
{ | |
echo 'stdout<<EOF' | |
docker compose --profile caddy ps -q | |
echo EOF | |
} >> "$GITHUB_OUTPUT" | |
- name: when caddy container is not running, start caddy container | |
if: steps.check-caddy-container.outputs.stdout == '' | |
run: > | |
docker compose --profile caddy up -d | |
- name: Start all containers except for caddy | |
run: | | |
docker compose --profile log --profile trace --profile metric up -d | |
- name: Restart all containers except for caddy | |
run: | | |
docker compose --profile log --profile trace --profile metric restart | |
- name: Set Caddyfile Environment Variables | |
run: | | |
sed -i 's/{$AWS_REQ_IP}/${{secrets.AWS_REQ_IP}}/' ./Caddyfile | |
- 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 |