Skip to content

fix: try with real commit from content repo #7

fix: try with real commit from content repo

fix: try with real commit from content repo #7

name: Update Content on Dispatch
on:
repository_dispatch:
types: [content-update]
push:
branches:
- main
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout main repo
uses: actions/checkout@v4
- name: Clone content repo
run: |
rm -rf src/content
git clone https://github.com/deviceofchoice/blog.git src/content
LAST_COMMIT_MSG=$(git -C src/content log --oneline -1 | cut -d' ' -f2-)
LAST_AUTHOR_NAME=$(git -C src/content log --format='%an' -1)
LAST_AUTHOR_EMAIL=$(git -C src/content log --format='%ae' -1)
rm -rf src/content/.git
echo "LAST_COMMIT_MSG=$LAST_COMMIT_MSG" >> $GITHUB_ENV
echo "LAST_AUTHOR_NAME=$LAST_AUTHOR_NAME" >> $GITHUB_ENV
echo "LAST_AUTHOR_EMAIL=$LAST_AUTHOR_EMAIL" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name "$LAST_AUTHOR_NAME"
git config --global user.email "$LAST_AUTHOR_EMAIL"
- name: Commit and push changes
run: |
git add src/content
git commit -m "[CONTENT] $LAST_COMMIT_MSG" || echo "No changes"
git push