Skip to content

check-draft-releases #168

check-draft-releases

check-draft-releases #168

name: check-draft-releases
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * *' # Every day at 8am UTC
jobs:
check-draft-releases:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v6
- uses: actions/create-github-app-token@v3
id: app-token
with:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Check for draft releases
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
echo "## Draft Releases Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Parse repos.yml for repos with immutable-releases: true
repos=$(yq eval '.repos[] | select(.["immutable-releases"] == true) | .repo' repos.yml)
found_drafts=false
issue_body=""
for repo in $repos; do
echo "Checking $repo for draft releases..."
# Get draft releases for the repo
draft_releases=$(gh api "repos/$repo/releases" --jq '.[] | select(.draft == true) | "- [\(.name // .tag_name)](\(.html_url)) (created: \(.created_at | split("T")[0]))"' 2>/dev/null || echo "")
if [ -n "$draft_releases" ]; then
found_drafts=true
echo "### [$repo](https://github.com/$repo)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "$draft_releases" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Build issue body
issue_body+="## [$repo](https://github.com/$repo)"$'\n\n'
issue_body+="$draft_releases"$'\n\n'
fi
done
if [ "$found_drafts" = false ]; then
echo "✅ No draft releases found in any repositories with immutable-releases enabled." >> $GITHUB_STEP_SUMMARY
else
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **Action Required:** The above draft releases should be reviewed and published." >> $GITHUB_STEP_SUMMARY
# Create issue with draft releases list
issue_body="The following draft releases were found and should be reviewed and published:"$'\n\n'"$issue_body"
gh issue create \
--repo "${{ github.repository }}" \
--title "Draft Releases Found - $(date +%Y-%m-%d)" \
--body "$issue_body" \
--assignee "${{ github.repository_owner }}"
fi