Skip to content

Commit

Permalink
Add CI jobs to reformat Blueprints and confirm a Blueprint is even sh…
Browse files Browse the repository at this point in the history
…ipped in a PR verify
  • Loading branch information
adamziel committed Apr 15, 2024
1 parent d0c6e90 commit 49d653f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 51 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/postprocess.yml
Original file line number Diff line number Diff line change
@@ -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;
44 changes: 0 additions & 44 deletions .github/workflows/reindex.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/ships-blueprint-json.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"useTabs": true
}
7 changes: 0 additions & 7 deletions make_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
]
Expand Down

0 comments on commit 49d653f

Please sign in to comment.