|
| 1 | +name: Discover New Credly Badges |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 6 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + discover-badges: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Fetch Credly Badges |
| 21 | + run: | |
| 22 | + curl -sL "https://www.credly.com/users/jacob-kraniak/badges.json?page=1&page_size=100" -o badges.json |
| 23 | +
|
| 24 | + - name: Process New Badges |
| 25 | + uses: actions/github-script@v7 |
| 26 | + with: |
| 27 | + script: | |
| 28 | + const fs = require('fs'); |
| 29 | + const badges = JSON.parse(fs.readFileSync('badges.json', 'utf8')).data || []; |
| 30 | +
|
| 31 | + const { data: existingIssues } = await github.rest.issues.listForRepo({ |
| 32 | + owner: context.repo.owner, |
| 33 | + repo: context.repo.repo, |
| 34 | + state: 'all', |
| 35 | + per_page: 100 |
| 36 | + }); |
| 37 | +
|
| 38 | + const existingTitles = new Set(existingIssues.map(i => i.title.toLowerCase())); |
| 39 | +
|
| 40 | + let created = 0; |
| 41 | + for (const badge of badges) { |
| 42 | + if (badge.state !== 'accepted' || !badge.badge_template) continue; |
| 43 | +
|
| 44 | + const name = badge.badge_template.name; |
| 45 | + const id = badge.id; |
| 46 | + const url = `https://www.credly.com/badges/${id}`; |
| 47 | + const title = `[Certification] ${name}`; |
| 48 | +
|
| 49 | + if (existingTitles.has(title.toLowerCase())) { |
| 50 | + console.log(`Skipping existing: ${name}`); |
| 51 | + continue; |
| 52 | + } |
| 53 | +
|
| 54 | + const issuedDate = badge.issued_at_date || 'Unknown'; |
| 55 | + const bodyLines = [ |
| 56 | + `**Credly Badge URL**: ${url}`, |
| 57 | + `**Credly Badge ID**: ${id}`, |
| 58 | + `**Date Certified**: ${issuedDate}`, |
| 59 | + '', |
| 60 | + '**Status:** Backlog', |
| 61 | + '**Target Completion:** TBD', |
| 62 | + '**Priority:** Medium', |
| 63 | + '', |
| 64 | + '## Overview', |
| 65 | + badge.badge_template.description || 'Certification earned on Credly.', |
| 66 | + '', |
| 67 | + `**Official Page:** ${badge.badge_template.url || 'https://www.credly.com'}`, |
| 68 | + '', |
| 69 | + '**Milestones / Tasks**', |
| 70 | + '- [ ] Claim badge on Credly (already done)', |
| 71 | + '- [ ] Add to Project Board', |
| 72 | + '- [ ] Update LinkedIn / resume', |
| 73 | + '- [ ] Plan renewal (if applicable)', |
| 74 | + '', |
| 75 | + '**Additional Labels:** credly, auto-created' |
| 76 | + ]; |
| 77 | + const body = bodyLines.join('\n'); |
| 78 | +
|
| 79 | + await github.rest.issues.create({ |
| 80 | + owner: context.repo.owner, |
| 81 | + repo: context.repo.repo, |
| 82 | + title: title, |
| 83 | + body: body, |
| 84 | + labels: ['certification', 'credly', 'auto-created'] |
| 85 | + }); |
| 86 | +
|
| 87 | + console.log(`Created issue for: ${name}`); |
| 88 | + created++; |
| 89 | + } |
| 90 | +
|
| 91 | + console.log(`Total new issues created: ${created}`); |
0 commit comments