Skip to content

Download upstream alerts #507

Download upstream alerts

Download upstream alerts #507

name: Download upstream alerts
on:
schedule:
- cron: '0 10 * * 1-5'
workflow_dispatch: {}
env:
COMPONENT_NAME: openshift4-logging
jobs:
alerts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '>=1.19.0'
- name: Download upstream alerts
run: make extract-alerts
- name: Commit changes to repository
run: |
set -e
if [[ -z $(git status --porcelain "${ALERTS_DIR}") ]]; then
echo "No changes to commit"
exit 0
fi
make gen-golden-all
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git switch -c "${ALERTS_UPDATES_BRANCH}"
git add "${ALERTS_DIR}" tests/golden
git commit -m "Update upstream alerts"
git push -u -f origin "${ALERTS_UPDATES_BRANCH}"
# Check if there is an existing PR that is OPEN or create a new one
gh pr view --json 'state' -q '.state == "OPEN" or halt_error(1)' || gh pr create --title "Update upstream alerts" --body "This PR updates the upstream alerts defined in alerts.txt." --label dependency
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ALERTS_DIR: component/extracted_alerts
ALERTS_UPDATES_BRANCH: dependencies/update-upstream-alerts