diff --git a/.github/actions/markdown2gempost/convert.sh b/.github/actions/markdown2gempost/convert.sh index a5743a7..13b3853 100644 --- a/.github/actions/markdown2gempost/convert.sh +++ b/.github/actions/markdown2gempost/convert.sh @@ -11,13 +11,6 @@ input_dir="${1%/}" output_dir="${2%/}" processed_dir="${3%/}" -# Find all .md files and check if the array is empty -mapfile -t md_files < <(find "$input_dir" -type f -name "*.md") -if [ ${#md_files[@]} -eq 0 ]; then - echo "No Markdown files to process." - exit 0 -fi - # Iterate over .md files in input directory for file in "$input_dir"/*.md; do file=$(basename "$file") diff --git a/.github/workflows/markdown2gempost.yml b/.github/workflows/markdown2gempost.yml index 19a4a4b..5dbdcb8 100644 --- a/.github/workflows/markdown2gempost.yml +++ b/.github/workflows/markdown2gempost.yml @@ -10,14 +10,36 @@ on: concurrency: group: md2gmi - cancel-in-progress: true + cancel-in-progress: false defaults: run: shell: bash jobs: + setup: + runs-on: ubuntu-latest + outputs: + work_to_do: ${{ steps.check_markdown.outputs.work_to_do }} + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.MY_GH_TOKEN }} + - name: Check for files to be processed + id: check_markdown + run: | + mapfile -t md_files < <(find markdown/incoming -type f -name "*.md") + if [ ${#md_files[@]} -eq 0 ]; then + echo "No Markdown files to process, exiting early." + echo "work_to_do=false" >> $GITHUB_OUTPUT + exit 0 + else + echo "work_to_do=true" >> $GITHUB_OUTPUT + fi + md2gmi: + needs: setup + if: needs.setup.outputs.work_to_do == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -31,5 +53,3 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: 'convert Markdown post to Gempost' - -