diff --git a/.github/workflows/postprocess.yml b/.github/workflows/postprocess.yml new file mode 100644 index 0000000..adacf0f --- /dev/null +++ b/.github/workflows/postprocess.yml @@ -0,0 +1,48 @@ +name: Post-process Blueprints after changes + +on: + push: + branches: + - trunk + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install Prettier + run: npm install -g prettier + - name: Run make_index.py + run: python make_index.py + - name: Run Prettier + run: prettier --write blueprints/**/*.json + - name: Check for uncommitted changes + id: changes + run: | + if [ -z "$(git status --porcelain)" ]; then + echo "No changes" + echo 'CHANGES=0' >> $GITHUB_OUTPUT + else + echo "Changes detected" + echo 'CHANGES=1' >> $GITHUB_OUTPUT + fi + - name: Setup SSH Keys + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.GH_DEPLOY_KEY }} + - name: Push rebuilt WordPress to GitHub + if: steps.changes.outputs.CHANGES == '1' + run: | + git config --global user.name "deployment_bot" + git config --global user.email "deployment_bot@users.noreply.github.com" + git add -A + git commit -a -m "Reindex Blueprints" + git pull --rebase + if [ $? -eq 0 ]; then + git push git@github.com:${{ github.repository }}.git --follow-tags + fi; diff --git a/.github/workflows/reindex.yml b/.github/workflows/reindex.yml deleted file mode 100644 index 5788a5e..0000000 --- a/.github/workflows/reindex.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Reindex Blueprints after changes - -on: - push: - branches: - - trunk - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Run make_index.py - run: python make_index.py - - name: Check for uncommitted changes - id: changes - run: | - if [ -z "$(git status --porcelain)" ]; then - echo "No changes" - echo 'CHANGES=0' >> $GITHUB_OUTPUT - else - echo "Changes detected" - echo 'CHANGES=1' >> $GITHUB_OUTPUT - fi - - name: Setup SSH Keys - uses: webfactory/ssh-agent@v0.5.3 - with: - ssh-private-key: ${{ secrets.GH_DEPLOY_KEY }} - - name: Push rebuilt WordPress to GitHub - if: steps.changes.outputs.CHANGES == '1' - run: | - git config --global user.name "deployment_bot" - git config --global user.email "deployment_bot@users.noreply.github.com" - git add -A - git commit -a -m "Reindex Blueprints" - git pull --rebase - if [ $? -eq 0 ]; then - git push git@github.com:${{ github.repository }}.git --follow-tags - fi; diff --git a/.github/workflows/ships-blueprint-json.yml b/.github/workflows/ships-blueprint-json.yml new file mode 100644 index 0000000..886d485 --- /dev/null +++ b/.github/workflows/ships-blueprint-json.yml @@ -0,0 +1,29 @@ +name: Ships Blueprint.json file? + +on: + pull_request: + branches: + - main + +jobs: + check_blueprints: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Find updated directories + id: find_directories + run: | + git diff --name-only origin/main...$GITHUB_SHA | grep '^blueprints/' | cut -d/ -f2 | sort -u > updated_directories.txt + + - name: Check blueprint.json files + id: check_blueprints + run: | + while IFS= read -r directory; do + if [ ! -f "blueprints/$directory/blueprint.json" ]; then + echo "Missing blueprint.json file in $directory" + exit 1 + fi + done < updated_directories.txt diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dfcc0e9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 4, + "useTabs": true +} diff --git a/make_index.py b/make_index.py index 51a4688..edd1b78 100644 --- a/make_index.py +++ b/make_index.py @@ -31,13 +31,6 @@ def get_dot_template_files(): def build_markdown_table(): with open('index.json', 'r') as f: index = json.load(f) - # blueprints_list = [] - # for path, meta in index.items(): - # blueprints_list.append('* {0} – [Preview]({1}) | [Source]({2})\n'.format( - # meta.get('title', ''), - # 'https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/' + path, - # 'https://github.com/adamziel/blueprints/blob/trunk/' + path - # )) blueprints_rows = [ ['Title', 'Preview', 'Source'] ]