diff --git a/.github/scripts/wordpress-plugins-update.py b/.github/scripts/wordpress-plugins-update.py index fa7f852382..041753ca2f 100644 --- a/.github/scripts/wordpress-plugins-update.py +++ b/.github/scripts/wordpress-plugins-update.py @@ -19,6 +19,7 @@ from bs4 import BeautifulSoup import requests import re from markdown import markdown +import os from termcolor import colored, cprint # Regex to extract the name of th plugin from the URL @@ -158,14 +159,25 @@ requests: regex: - '(?i)Stable.tag:\s?([\w.]+)' ''' - version_file = open( - f"helpers/wordpress/plugins/{name}.txt", "w") + + work_dir = os.getcwd() + print(f"Current working directory: {work_dir}") + helper_dir = f"{work_dir}/helpers/wordpress/plugins" + template_dir = f"{work_dir}/technologies/wordpress/plugins" + + if not os.path.exists(helper_dir): + os.makedirs(helper_dir) + + if not os.path.exists(template_dir): + os.makedirs(template_dir) + + helper_path = f"helpers/wordpress/plugins/{name}.txt" + version_file = open(helper_path, "w") version_file.write(version) version_file.close() - # print(template) - template_file = open( - f"technologies/wordpress/plugins/{name}.yaml", "w") + template_path = f"technologies/wordpress/plugins/{name}.yaml" + template_file = open(template_path, "w") # Dev environment template_file.write(template) template_file.close() diff --git a/.github/workflows/wordpress-plugins-update.yml b/.github/workflows/wordpress-plugins-update.yml index 63bdc67c3c..20c2102261 100644 --- a/.github/workflows/wordpress-plugins-update.yml +++ b/.github/workflows/wordpress-plugins-update.yml @@ -7,9 +7,6 @@ jobs: Update: runs-on: ubuntu-latest steps: - - name: Install tree - run: sudo apt-get install tree -y - - name: Check out repository code uses: actions/checkout@v3 with: @@ -25,19 +22,21 @@ jobs: pip install -r .github/scripts/wordpress-plugins-update-requirements.txt - name: Update Templates + id: update-templates run: | python3 .github/scripts/wordpress-plugins-update.py git status -s | wc -l | xargs -I {} echo CHANGES={} >> $GITHUB_OUTPUT - name: Commit files - if: steps.readme-update.outputs.CHANGES > 0 + if: steps.update-templates.outputs.CHANGES > 0 run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git commit -m "Auto WordPress Plugins Update [$(date)] :robot:" -a + git add --all + git commit -m "Auto WordPress Plugins Update [$(date)] :robot:" - name: Push changes - if: steps.readme-update.outputs.CHANGES > 0 + if: steps.update-templates.outputs.CHANGES > 0 uses: ad-m/github-push-action@master with: github_token: ${{ secrets.TOKEN }}