Skip to content

Commit bd53944

Browse files
committed
chore: update content sync workflow and remove outdated debug files
1 parent 63eec11 commit bd53944

3 files changed

Lines changed: 64 additions & 710 deletions

File tree

.github/workflows/content-sync.yml

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,77 @@ name: Content Sync
22

33
on:
44
push:
5-
branches:
6-
- main
7-
paths:
8-
- 'Content/**'
5+
branches: [main]
6+
paths: ['Content/**']
7+
workflow_dispatch:
8+
schedule:
9+
- cron: '0 0 * * *' # Run daily at midnight UTC
910

1011
jobs:
1112
sync-content:
1213
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
1316

1417
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
1719

18-
- name: Setup .NET
19-
uses: actions/setup-dotnet@v4
20-
with:
21-
dotnet-version: '9.0.x'
20+
- name: Count Content Articles
21+
id: count-articles
22+
shell: pwsh
23+
run: |
24+
$count = (Get-ChildItem -Path "Content" -Recurse -File -Filter "*.md").Count
25+
"article-count=$count" >> $env:GITHUB_OUTPUT
26+
27+
- uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: '9.0.x'
2230

23-
- name: Build ContentLoader
24-
run: |
25-
dotnet build ContentLoader/ContentLoader.csproj --configuration Release
31+
- name: Build ContentLoader
32+
run: dotnet build ContentLoader/ContentLoader.csproj --configuration Release
2633

27-
- name: Upload Content
28-
env:
29-
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.CONTENT_STORAGE_CONNECTION_STRING }}
30-
run: dotnet run --project ContentLoader/ContentLoader.csproj --configuration Release -- Content
34+
- name: Upload Content
35+
env:
36+
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.CONTENT_STORAGE_CONNECTION_STRING }}
37+
run: dotnet run --project ContentLoader/ContentLoader.csproj --configuration Release -- Content
3138

32-
- name: Handle Failure
33-
if: failure()
34-
run: |
35-
echo "Content sync failed. Check the build output and Azure Storage connection string."
36-
exit 1
39+
- name: Handle Failure
40+
if: failure()
41+
run: |
42+
echo "Content sync failed. Check the build output and Azure Storage connection string."
43+
exit 1
44+
45+
- name: Update README Badges
46+
if: success()
47+
shell: pwsh
48+
run: |
49+
$date = Get-Date -Format "yyyy-MM-dd"
50+
$articleCount = "${{ steps.count-articles.outputs.article-count }}"
51+
52+
# Create badge URLs using shields.io
53+
$lastUpdateBadge = "![Content Last Updated](https://img.shields.io/badge/Content%20Last%20Updated-${date}-blue)"
54+
$articleCountBadge = "![Content Articles](https://img.shields.io/badge/Content%20Articles-${articleCount}-green)"
55+
56+
# Read current README content
57+
$readmeContent = Get-Content README.md -Raw
58+
59+
# Replace existing badges or add new ones at the top of the file
60+
$badgeSection = "${lastUpdateBadge}`n${articleCountBadge}`n"
61+
62+
if ($readmeContent -match "!\[Content Last Updated\].*`n!\[Content Articles\].*`n") {
63+
$readmeContent = $readmeContent -replace "!\[Content Last Updated\].*`n!\[Content Articles\].*`n", $badgeSection
64+
} else {
65+
$readmeContent = $badgeSection + $readmeContent
66+
}
67+
68+
# Write updated content back to README
69+
$readmeContent | Set-Content README.md -NoNewline
70+
71+
- name: Commit README Changes
72+
if: success()
73+
run: |
74+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
75+
git config --local user.name "github-actions[bot]"
76+
git add README.md
77+
git commit -m "docs: update content sync badges [skip ci]" || exit 0
78+
git push

0 commit comments

Comments
 (0)