Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update channel and message details in notify-mattermost-cloud-dependa… #134

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/notify-mattermost-cloud-dependapot-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
description: "Exit this job/workflow with the monitored job status. Options: true or false. Default: true"
type: string
default: "true"
highlight:
description: "Mattermost highlight. Default: pdcloudtestalerts"
channel:
description: "Mattermost channel. Default: pdcloudtestalerts"
type: string
default: "pdcloudtestalerts"
status:
Expand All @@ -38,6 +38,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GREENBONE_BOT_TOKEN }}
run: |
SEVEN_DAYS_AGO=$(date -d '7 days ago' +%s)
REPO_NAME=${{ github.repository }}
gh pr list --label "dependencies" --state "open" --json url,createdAt,title > all_dependabot_prs.json

OLD_PRS=$(cat all_dependabot_prs.json | jq --argjson cutoff "$SEVEN_DAYS_AGO" \
Expand All @@ -48,7 +49,11 @@ jobs:
else
echo "$OLD_PRS" | jq -r '. | "- **\(.title)**: [View PR](\(.url))"' > old_pr_list.txt
echo "OLD_PRS_FOUND=true" >> $GITHUB_OUTPUT
MESSAGE_TEXT=$(<old_pr_list.txt)
{
echo "[DEPENDABOT ALERT] :warning: Overdue Dependabot PRs in Repository: $REPO_NAME"
cat old_pr_list.txt
} > message_with_header.txt
MESSAGE_TEXT=$(<message_with_header.txt)
echo "MESSAGE_TEXT<<EOF" >> $GITHUB_OUTPUT
echo "$MESSAGE_TEXT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
Expand All @@ -59,7 +64,7 @@ jobs:
uses: greenbone/actions/mattermost-notify@a1883bd24d2d921426b3f06413e84606ecd43bdd # v3.27.11
with:
url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
channel: "pdcloudtestalerts"
channel: ${{ inputs.channel }}
message: ${{ steps.fetch_prs.outputs.MESSAGE_TEXT }}
repository: ${{ github.repository }}
commit: ${{ github.sha }}
Expand Down