test CI #6
Workflow file for this run
This file contains hidden or 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: "Prometheus Rules" | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - add-promtool | |
| paths: | |
| - observability/prometheus/rules/**/*.y*ml | |
| jobs: | |
| rules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| name: Checkout code | |
| - name: Install Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: "go.mod" | |
| - name: Create Prometheus rule file | |
| run: | | |
| make install-tools | |
| cd observability/prometheus/ | |
| echo "# This file got auto-generated by GitHub workflow '$GITHUB_WORKFLOW'" > rule-file.yml | |
| cat >> rule-file.yml << EOF | |
| --- | |
| groups: | |
| - name: rabbitmq-cluster-operator | |
| rules: [] | |
| - name: rabbitmq | |
| rules: [] | |
| EOF | |
| find rules/rabbitmq-cluster-operator -name "*.y*ml" -exec yq eval-all --inplace --no-colors --prettyPrint 'select(fileIndex==0).groups.[0].rules = select(fileIndex==0).groups.[0].rules + select(fileIndex==1).spec.groups.[0].rules | select(fileIndex==0)' rule-file.yml {} ';' | |
| append_rabbitmq_rules='select(fileIndex==0).groups.[1].rules = select(fileIndex==0).groups.[1].rules + select(fileIndex==1).spec.groups.[0].rules | select(fileIndex==0)' | |
| find rules/rabbitmq -name "*.y*ml" ! -name recording-rules.yml -exec yq eval-all --inplace --no-colors --prettyPrint "$append_rabbitmq_rules" rule-file.yml {} ';' | |
| yq eval-all --inplace --no-colors --prettyPrint "$append_rabbitmq_rules" rule-file.yml rules/rabbitmq/recording-rules.yml | |
| - name: Check Prometheus rule file | |
| run: | | |
| make install-tools | |
| promtool check rules observability/prometheus/rule-file.yml | |
| - name: Commit Prometheus rule file | |
| working-directory: observability/prometheus | |
| run: | | |
| if [[ `git status --porcelain -- rule-file.yml` ]]; then | |
| git config --global user.name 'RabbitMQ CI Bot' | |
| git config --global user.email '[email protected]' | |
| git add -- rule-file.yml | |
| git commit -m "Update Prometheus rule file" | |
| git push | |
| fi |