notify-stalled-snapshots #5
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
--- | |
name: notify-stalled-snapshots | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 1 * * 1' | |
permissions: | |
contents: read | |
env: | |
EMAIL: [email protected] | |
URL_QUERY: 'https://github.com/elastic/beats/pulls?q=is%3Apr+is%3Aopen+label%3ATeam%3ABeats-On-Call' | |
JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
jobs: | |
filter: | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
outputs: | |
matrix: ${{ steps.generator.outputs.matrix }} | |
steps: | |
- id: generator | |
uses: elastic/oblt-actions/elastic/active-branches@v1 | |
notify: | |
runs-on: ubuntu-latest | |
needs: [filter] | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.filter.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: "${{ matrix.branch }}" | |
- id: date | |
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" | |
- id: search | |
run: |- | |
if git --no-pager \ | |
log --pretty=format: \ | |
--name-only \ | |
--since="7 days ago" \ | |
| grep 'testing/environments/snapshot.yml' ; then | |
echo "found=false" >> $GITHUB_OUTPUT | |
else | |
echo "found=true" >> $GITHUB_OUTPUT | |
fi | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- if: ${{ contains(steps.search.outputs.found, 'true') }} | |
name: Report obsoleted branches (slack) | |
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0 | |
with: | |
channel-id: '#ingest-notifications' | |
payload: ":red_circle: Elastic Stack version for the `${{ matrix.branch }}` branch has not been updated for a while (`> 7 days`). Review the (<${{ env.URL_QUERY }}|open PRs>)" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
- if: ${{ contains(steps.search.outputs.found, 'true') }} | |
name: Report obsoleted branches (email) | |
uses: dawidd6/action-send-mail@2cea9617b09d79a095af21254fbcb7ae95903dde | |
with: | |
server_address: ${{ secrets.MAIL_SERVER }} | |
username: ${{ secrets.MAIL_USERNAME }} | |
password: ${{ secrets.MAIL_PASSWORD }} | |
subject: '[${{ matrix.branch }}] ${{ steps.date.outputs.date }}: Elastic Stack version has not been updated recently.' | |
to: ${{ env.EMAIL }} | |
from: ${{ secrets.MAIL_FROM }} | |
reply_to: ${{ secrets.MAIL_REPLY }} | |
body: 'Elastic Stack version for the ${{ matrix.branch }} branch has not been updated for a while (> 7 days). Review the open PRs in ${{ env.URL_QUERY }}. Generated automatically with ${{ env.JOB_URL }}' |