Skip to content

Commit 49d653f

Browse files
committed
Add CI jobs to reformat Blueprints and confirm a Blueprint is even shipped in a PR verify
1 parent d0c6e90 commit 49d653f

File tree

5 files changed

+81
-51
lines changed

5 files changed

+81
-51
lines changed

.github/workflows/postprocess.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Post-process Blueprints after changes
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Python 3.8
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.8
18+
- name: Install Prettier
19+
run: npm install -g prettier
20+
- name: Run make_index.py
21+
run: python make_index.py
22+
- name: Run Prettier
23+
run: prettier --write blueprints/**/*.json
24+
- name: Check for uncommitted changes
25+
id: changes
26+
run: |
27+
if [ -z "$(git status --porcelain)" ]; then
28+
echo "No changes"
29+
echo 'CHANGES=0' >> $GITHUB_OUTPUT
30+
else
31+
echo "Changes detected"
32+
echo 'CHANGES=1' >> $GITHUB_OUTPUT
33+
fi
34+
- name: Setup SSH Keys
35+
uses: webfactory/[email protected]
36+
with:
37+
ssh-private-key: ${{ secrets.GH_DEPLOY_KEY }}
38+
- name: Push rebuilt WordPress to GitHub
39+
if: steps.changes.outputs.CHANGES == '1'
40+
run: |
41+
git config --global user.name "deployment_bot"
42+
git config --global user.email "[email protected]"
43+
git add -A
44+
git commit -a -m "Reindex Blueprints"
45+
git pull --rebase
46+
if [ $? -eq 0 ]; then
47+
git push [email protected]:${{ github.repository }}.git --follow-tags
48+
fi;

.github/workflows/reindex.yml

-44
This file was deleted.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Ships Blueprint.json file?
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check_blueprints:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Find updated directories
17+
id: find_directories
18+
run: |
19+
git diff --name-only origin/main...$GITHUB_SHA | grep '^blueprints/' | cut -d/ -f2 | sort -u > updated_directories.txt
20+
21+
- name: Check blueprint.json files
22+
id: check_blueprints
23+
run: |
24+
while IFS= read -r directory; do
25+
if [ ! -f "blueprints/$directory/blueprint.json" ]; then
26+
echo "Missing blueprint.json file in $directory"
27+
exit 1
28+
fi
29+
done < updated_directories.txt

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 4,
3+
"useTabs": true
4+
}

make_index.py

-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ def get_dot_template_files():
3131
def build_markdown_table():
3232
with open('index.json', 'r') as f:
3333
index = json.load(f)
34-
# blueprints_list = []
35-
# for path, meta in index.items():
36-
# blueprints_list.append('* {0} – [Preview]({1}) | [Source]({2})\n'.format(
37-
# meta.get('title', ''),
38-
# 'https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/' + path,
39-
# 'https://github.com/adamziel/blueprints/blob/trunk/' + path
40-
# ))
4134
blueprints_rows = [
4235
['Title', 'Preview', 'Source']
4336
]

0 commit comments

Comments
 (0)