name: Dependabot Agentic Check
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
dependabot-check:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Build Project
run: npm run build
- name: Run Dependabot Agent Check
id: check
run: npm run dependabot-check
continue-on-error: true
- name: Read Report
id: report
if: always()
run: |
if [ -f dependabot-report.md ]; then
CONTENT=$(cat dependabot-report.md)
echo "report<<EOF" >> $GITHUB_OUTPUT
echo "$CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Comment on PR
if: always() && steps.report.outputs.report != ''
uses: actions/github-script@v7
with:
script: |
const report = process.env.REPORT;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: report
});
env:
REPORT: ${{ steps.report.outputs.report }}
- name: Fail if check failed
if: steps.check.outcome == 'failure'
run: exit 1