jobs:
sync:
runs-on: ubuntu-latest
+ outputs:
+ changed_files: ${{ steps.commit.outputs.changed_files }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
run: python .github/scripts/medium_to_hugo.py
- name: Commit and push changes
+ id: commit
run: |
git config user.name "Medium Sync Bot"
git config user.email "actions@github.com"
git add content/posts/
- git diff --quiet && git diff --staged --quiet || git commit -m "Sync new Medium posts"
- git push
+
+ # Check if there are any changes to commit
+ if git diff --quiet && git diff --staged --quiet; then
+ echo "No changes to commit"
+ echo "changed_files=0" >> $GITHUB_OUTPUT
+ else
+ # Count the number of changed files
+ changed_count=$(git diff --name-only --diff-filter=ACMR HEAD | wc -l)
+ git commit -m "Sync new Medium posts"
+ git push
+ echo "changed_files=$changed_count" >> $GITHUB_OUTPUT
+ fi
+
+ publish:
+ runs-on: ubuntu-latest
+ needs: sync
+ if: needs.sync.outputs.changed_files > 0
+ steps:
+ - name: Run hugo workflow
+ uses: ./.github/workflows/hugo.yml