-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (108 loc) · 4.58 KB
/
profile-summary-cards.yml
File metadata and controls
121 lines (108 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: GitHub-Profile-Summary-Cards
on:
schedule: # execute every 24 hours
- cron: "30 0 * * *" # Executes at 00:30 UTC daily
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: generate-github-cards
permissions:
contents: write
steps:
- name: Check if secrets are available
id: check-secrets
env:
HAS_SECRET: ${{ secrets.PERSONAL_ACCESS_KEY != '' }}
run: |
if [ "$HAS_SECRET" != "true" ]; then
echo "secret_available=false" >> $GITHUB_OUTPUT
echo "::warning::PERSONAL_ACCESS_KEY secret is not configured. Skipping profile cards generation."
else
echo "secret_available=true" >> $GITHUB_OUTPUT
fi
- name: Get current date
if: steps.check-secrets.outputs.secret_available == 'true'
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
# Cache npm dependencies and GitHub API responses
- name: Cache dependencies
if: steps.check-secrets.outputs.secret_available == 'true'
uses: actions/cache@v4
with:
path: |
~/.npm
~/.cache/profile-summary-cards
key: profile-summary-${{ steps.date.outputs.date }}
restore-keys: |
profile-summary-
# CRITICAL: First checkout this profile repository
- name: Checkout profile repository
if: steps.check-secrets.outputs.secret_available == 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PERSONAL_ACCESS_KEY }}
# Then checkout the private action to a nested path
- name: Checkout private action repository
if: steps.check-secrets.outputs.secret_available == 'true'
uses: actions/checkout@v4
with:
repository: szmyty/github-profile-summary-cards
ref: main
token: ${{ secrets.PERSONAL_ACCESS_KEY }}
path: .github/actions/profile-summary-cards
continue-on-error: true
# Configure git for committing
- name: Configure git
if: steps.check-secrets.outputs.secret_available == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Run the action from the nested path
- name: Generate profile summary cards
if: steps.check-secrets.outputs.secret_available == 'true'
uses: ./.github/actions/profile-summary-cards
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_KEY }}
with:
USERNAME: ${{ github.repository_owner }}
continue-on-error: true
# Verify output files were generated
- name: Verify generated files
if: steps.check-secrets.outputs.secret_available == 'true'
id: verify
run: |
echo "=== Checking for generated output ==="
if [ -d "profile-summary-card-output" ]; then
echo "output_exists=true" >> $GITHUB_OUTPUT
echo "✅ profile-summary-card-output directory exists"
echo "Files generated:"
find profile-summary-card-output -type f -name "*.svg" | head -20
SVG_COUNT=$(find profile-summary-card-output -type f -name "*.svg" | wc -l)
echo "svg_count=$SVG_COUNT" >> $GITHUB_OUTPUT
echo "Total SVG files: $SVG_COUNT"
else
echo "output_exists=false" >> $GITHUB_OUTPUT
echo "❌ profile-summary-card-output directory not found"
fi
# Commit and push generated cards
- name: Commit and push changes
if: steps.check-secrets.outputs.secret_available == 'true' && steps.verify.outputs.output_exists == 'true'
run: |
# Remove the nested action directory before committing
rm -rf .github/actions/profile-summary-cards
# Check if there are changes to commit
if git diff --quiet && git diff --staged --quiet; then
echo "No changes to commit"
else
git add profile-summary-card-output/
git commit -m "Update profile summary cards - ${{ steps.date.outputs.date }}" || echo "Nothing to commit"
git push origin HEAD
echo "✅ Changes committed and pushed successfully"
fi
# Log if generation failed
- name: Log generation status
if: steps.check-secrets.outputs.secret_available == 'true' && steps.verify.outputs.output_exists != 'true'
run: |
echo "::warning::Profile summary cards were not generated. Check the action logs for details."