69 lines
2.1 KiB
Markdown
69 lines
2.1 KiB
Markdown
name: Weekly Health Report
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 9 * * 1"
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: health-report-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
health-check:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6
|
|
|
|
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # ratchet:actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build
|
|
run: go build -o awesome-docker ./cmd/awesome-docker
|
|
|
|
- name: Run Health + Report
|
|
id: report
|
|
run: ./awesome-docker ci health-report --issue-file health_report.txt --github-output "$GITHUB_OUTPUT"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create/Update Issue with Health Report
|
|
if: steps.report.outputs.has_report == 'true'
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # ratchet:actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const report = fs.readFileSync('health_report.txt', 'utf8');
|
|
const issueBody = report;
|
|
|
|
const issues = await github.rest.issues.listForRepo({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
state: 'open',
|
|
labels: 'health-report',
|
|
per_page: 1
|
|
});
|
|
|
|
if (issues.data.length > 0) {
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issues.data[0].number,
|
|
body: issueBody
|
|
});
|
|
} else {
|
|
await github.rest.issues.create({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
title: 'Weekly Health Report - Repository Maintenance Needed',
|
|
body: issueBody,
|
|
labels: ['health-report', 'maintenance']
|
|
});
|
|
}
|