-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 95f9aa8
Showing
10 changed files
with
2,030 additions
and
0 deletions.
There are no files selected for viewing
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,69 @@ | ||
name: Update Dashboards & Deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
update-dashboards: | ||
name: Update Dashboards | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install dependencies | ||
run: sudo apt-get install -y jq | ||
|
||
- name: Get UNIX_TIMESTAMP | ||
run: | | ||
UNIX_TIMESTAMP=$(date +%s) | ||
echo "UNIX_TIMESTAMP=$UNIX_TIMESTAMP" >> $GITHUB_ENV | ||
- name: Run update_dashboards.sh | ||
env: | ||
DASHBOARD_DIR: "./grafana/dashboards" | ||
GRAFANA_URL: ${{ secrets.GRAFANA_URL }} | ||
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} | ||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | ||
UNIX_TIMESTAMP: ${{ env.UNIX_TIMESTAMP }} | ||
run: | | ||
chmod +x grafana/update_dashboards.sh | ||
./grafana/update_dashboards.sh | ||
deploy: | ||
name: Deploy Grafana | ||
runs-on: self-hosted | ||
needs: update-dashboards | ||
env: | ||
GRAFANA_HOST: "10.10.0.108" | ||
DOCKER_CONTEXT_NAME: grafana-ctx | ||
DOCKER_PROJECT_NAME: grafana | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run command on remote server via SSH | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ env.GRAFANA_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
script: | | ||
cd /data/grafana | ||
git pull origin main | ||
- name: Set up Docker context | ||
run: | | ||
docker context \ | ||
create ${{ env.DOCKER_CONTEXT_NAME }} \ | ||
--docker host="tcp://${{ env.GRAFANA_HOST }}:2375" | ||
- name: Deploy with Docker Compose | ||
run: | | ||
docker --context ${{ env.DOCKER_CONTEXT_NAME }} compose \ | ||
--project-name ${{ env.DOCKER_PROJECT_NAME }} up -d --remove-orphans --force-recreate | ||
- name: Cleanup Docker context | ||
if: always() | ||
run: | | ||
docker context rm ${{ env.DOCKER_CONTEXT_NAME }} --force |
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,2 @@ | ||
.env | ||
run.sh |
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,6 @@ | ||
{ | ||
"[json]": { | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": false | ||
} | ||
} |
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,45 @@ | ||
name: grafana | ||
services: | ||
grafana: | ||
image: grafana/grafana | ||
container_name: grafana | ||
restart: unless-stopped | ||
ports: | ||
- '3000:3000' | ||
volumes: | ||
- grafana_data:/var/lib/grafana | ||
environment: | ||
- GF_LOG_LEVEL=error | ||
|
||
prometheus: | ||
image: prom/prometheus | ||
container_name: prometheus | ||
volumes: | ||
- /data/grafana/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml | ||
- prometheus_data:/prometheus | ||
ports: | ||
- '9090:9090' | ||
command: | ||
- '--config.file=/etc/prometheus/prometheus.yml' | ||
- '--storage.tsdb.path=/prometheus' | ||
- '--storage.tsdb.retention.time=14d' | ||
- '--web.console.libraries=/etc/prometheus/console_libraries' | ||
- '--web.console.templates=/etc/prometheus/consoles' | ||
- '--web.enable-lifecycle' | ||
restart: unless-stopped | ||
|
||
loki: | ||
image: grafana/loki | ||
container_name: loki | ||
restart: unless-stopped | ||
ports: | ||
- "3100:3100" | ||
command: -config.file=/etc/loki/local-config.yaml | ||
volumes: | ||
- loki_data:/loki | ||
- /data/grafana/loki/loki-config.yaml:/etc/loki/local-config.yaml | ||
|
||
volumes: | ||
grafana_data: | ||
prometheus_data: | ||
loki_data: |
Oops, something went wrong.