Skip to content

fix: correct formatting issue in publishedDate field #13

fix: correct formatting issue in publishedDate field

fix: correct formatting issue in publishedDate field #13

Workflow file for this run

name: Content Sync
on:
push:
branches: [main]
paths: ['Content/**']
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Run daily at midnight UTC
jobs:
sync-content:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Count Content Articles
id: count-articles
shell: pwsh
run: |
$count = (Get-ChildItem -Path "Content" -Recurse -File -Filter "*.md").Count
"article-count=$count" >> $env:GITHUB_OUTPUT
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Build ContentLoader
run: dotnet build ContentLoader/ContentLoader.csproj --configuration Release
- name: Upload Content
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.CONTENT_STORAGE_CONNECTION_STRING }}
run: dotnet run --project ContentLoader/ContentLoader.csproj --configuration Release -- Content
- name: Refresh Web App Cache
if: success()
env:
CACHE_REFRESH_API_KEY: ${{ secrets.CACHE_REFRESH_API_KEY }}
run: |
echo "Refreshing web application cache..."
# Wait a moment for the content to be fully uploaded
sleep 5
# Call the cache refresh endpoint with API key authentication
response=$(curl -s -w "%{http_code}" -X POST "https://copilotthatjawn.com/api/cache/refresh" \
-H "X-API-Key: $CACHE_REFRESH_API_KEY" \
-o /tmp/cache_response.json)
if [ "$response" = "200" ]; then
echo "Cache refresh successful"
cat /tmp/cache_response.json
else
echo "Cache refresh failed with HTTP status: $response"
cat /tmp/cache_response.json || echo "No response body"
# Don't fail the workflow if cache refresh fails - it's not critical
echo "Continuing workflow despite cache refresh failure..."
fi
- name: Handle Failure
if: failure()
run: |
echo "Content sync failed. Check the build output and Azure Storage connection string."
exit 1
- name: Update README Badges
if: success()
shell: pwsh
run: |
$date = Get-Date -Format "yyyy--MM--dd"
$articleCount = "${{ steps.count-articles.outputs.article-count }}"
# Create badge URLs using shields.io
$lastUpdateBadge = "![Content Last Updated](https://img.shields.io/badge/Content%20Last%20Updated-${date}-blue)"
$articleCountBadge = "![Content Articles](https://img.shields.io/badge/Content%20Articles-${articleCount}-green)"
# Read current README content
$readmeContent = Get-Content README.md -Raw
# Replace existing badges or add new ones at the top of the file
$badgeSection = "${lastUpdateBadge}`n${articleCountBadge}`n"
if ($readmeContent -match "!\[Content Last Updated\].*`n!\[Content Articles\].*`n") {
$readmeContent = $readmeContent -replace "!\[Content Last Updated\].*`n!\[Content Articles\].*`n", $badgeSection
} else {
$readmeContent = $badgeSection + $readmeContent
}
# Write updated content back to README
$readmeContent | Set-Content README.md -NoNewline
- name: Commit README Changes
if: success()
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "docs: update content sync badges [skip ci]" || exit 0
git push