mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-21 00:47:18 +08:00
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
publish:
|
|
name: Publish
|
|
# Check if the PR is not from a fork
|
|
if: github.repository_owner == 'samber'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 2.7
|
|
|
|
- name: Set up yq
|
|
uses: mikefarah/yq@master
|
|
|
|
- name: Install liquid
|
|
run: gem install liquid-cli
|
|
|
|
- name: Build rule configuration
|
|
run: |
|
|
gem install liquid-cli
|
|
cat _data/rules.yml | yq -I 0 -o json > _data/rules.json
|
|
|
|
rm -rf dist/rules
|
|
|
|
for service in $(cat _data/rules.json | jq -r '.groups[].services[] | @base64'); do
|
|
subdir=dist/rules/$(echo ${service} | base64 --decode | jq -r '.name | ascii_downcase | split(" ") | join("-")')
|
|
mkdir -p "${subdir}"
|
|
|
|
# groupName=$(echo "{% assign groupName = name | split: ' ' %}{% capture groupNameCamelcase %}{% for word in groupName %}{{ word | capitalize }} {% endfor %}{% endcapture %} {{ groupNameCamelcase | remove: ' ' | remove: '-' }}" | liquid $(echo ${service} | base64 --decode | jq -r '.name | ascii_downcase | split(" ") | join("-")'))
|
|
|
|
for exporter in $(echo ${service} | base64 --decode | jq -r '.exporters[] | @base64'); do
|
|
exporterName=$(echo ${exporter} | base64 --decode | jq -r '.slug')
|
|
cat dist/template.yml | liquid "$(echo ${exporter} | base64 --decode)" > ${subdir}/${exporterName}.yml
|
|
echo ${subdir}/${exporterName}.yml
|
|
done
|
|
done
|
|
|
|
rm _data/rules.json
|
|
|
|
# https://peterevans.dev/posts/github-actions-how-to-automate-code-formatting-in-pull-requests/
|
|
- name: Check for modified files
|
|
id: git-check
|
|
run: echo ::set-output name=modified::$(git status -s --porcelain | wc -l | awk '{$1=$1};1')
|
|
- name: Push changes
|
|
if: steps.git-check.outputs.modified != '0'
|
|
run: |
|
|
git config --global user.name 'samber'
|
|
git config --global user.email 'samber@users.noreply.github.com'
|
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
|
git add .
|
|
git commit -m "Publish"
|
|
git push
|