diff --git a/.github/workflows/process_mdx_file.yml b/.github/workflows/process_mdx_file.yml new file mode 100644 index 00000000..c8815da1 --- /dev/null +++ b/.github/workflows/process_mdx_file.yml @@ -0,0 +1,49 @@ +name: Process MDX Files + +on: + pull_request: + paths: + - '**/*.mdx' + +jobs: + process-mdx: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + + - name: Run image processing script + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: python process_images.py + + - name: Check for changes + id: git_status + run: | + if [[ -z $(git status --porcelain) ]]; then + echo "::set-output name=changes::false" + else + echo "::set-output name=changes::true" + fi + + - name: Commit and push changes + if: steps.git_status.outputs.changes == 'true' + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add . + git commit -m "Processed images in MDX files" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}