Skip to content

Publish

Publish #10

Workflow file for this run

name: Publish
on:
schedule:
# Runs at 11:00 UTC on weekdays only (Mon-Fri)
- cron: '0 11 * * 1-5'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup timezone
run: |
sudo timedatectl set-timezone Europe/Berlin || true
echo "Current time in Berlin: $(TZ=Europe/Berlin date '+%Y-%m-%d %H:%M:%S')"
- name: Get current date
id: date
run: |
CURRENT_DATE=$(TZ=Europe/Berlin date '+%Y-%m-%d')
echo "current_date=${CURRENT_DATE}" >> $GITHUB_OUTPUT
echo "Current date: ${CURRENT_DATE}"
- name: Find and update news files
id: update
run: |
CURRENT_DATE="${{ steps.date.outputs.current_date }}"
echo "Looking for news with date: ${CURRENT_DATE}"
CHANGED=false
# Find all index.yml files in src/news/
while read -r file; do
# Check if the file contains the current date
if grep -q "^date: ${CURRENT_DATE}" "$file"; then
echo "Found news file with current date: $file"
# Check if it has permalink: false
if grep -q "^permalink: false" "$file"; then
echo "Removing 'permalink: false' from $file"
# Remove empty line before permalink and the permalink: false line
sed -i '/^$/{ N; /\npermalink: false$/d; }; /^permalink: false$/d' "$file"
CHANGED=true
else
echo "File already published (no 'permalink: false' found)"
fi
fi
done < <(find src/news -type f -name "index.yml")
echo "changed=${CHANGED}" >> $GITHUB_OUTPUT
- name: Commit and push changes
if: steps.update.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add src/news/
git commit -m "Publish news"
git push