From bd9935988a6d43449432364820acd47cd1aed7e5 Mon Sep 17 00:00:00 2001 From: xangelo Date: Mon, 21 Jul 2025 15:16:20 -0400 Subject: [PATCH] run publish workflow after successful sync --- .github/workflows/medium-sync.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/medium-sync.yml b/.github/workflows/medium-sync.yml index 7a7d966..07ad830 100644 --- a/.github/workflows/medium-sync.yml +++ b/.github/workflows/medium-sync.yml @@ -8,6 +8,8 @@ on: jobs: sync: runs-on: ubuntu-latest + outputs: + changed_files: ${{ steps.commit.outputs.changed_files }} steps: - name: Checkout repo uses: actions/checkout@v4 @@ -24,9 +26,28 @@ jobs: 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 -- 2.25.1