-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (50 loc) · 1.34 KB
/
update-hosts.yml
File metadata and controls
50 lines (50 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Update Hosts
on:
workflow_dispatch:
push:
branches:
- master
paths:
- files/hosts/*
jobs:
update-hosts:
name: update-hosts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: generate config for prometheus
run: |
jq -sR '
[
.
| split("\n")[]
| split(" ")
| select(length == 2)
| {
targets: [
"\(.[1]):9100",
"\(.[1]):9256"
],
labels: {
hostname: .[0],
ip: .[1]
}
}
]
' files/hosts/* > etc/prometheus/hosts.json
- name: config git
run: |
git config user.name $GITHUB_ACTOR
git config user.email $GITHUB_ACTOR@users.noreply.github.com
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout master
- name: git commit
run: |
git add -f etc/prometheus/hosts.json
git commit -m 'Update config for prometheus'
- name: git push
run: |
git pull origin master
git push origin master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}