Skip to content

Commit 727be0d

Browse files
committed
ci: Consolidate build and deploy workflows
This commit combines the separate `build.yml` and `deploy.yml` GitHub Action workflows into a single, sequential workflow in `deploy.yml`. The new workflow ensures a predictable order of operations: 1. Build the plugin and its `dist` artifacts. 2. Build the Docusaurus example site. 3. Deploy the site to GitHub Pages. 4. Commit the potentially updated `dist` directory back to the repository. This resolves a workflow loop issue where a push from one action would not trigger the other, ensuring the deployment always uses the latest build of the plugin. The redundant `build.yml` has been deleted.
1 parent 423a474 commit 727be0d

File tree

2 files changed

+20
-54
lines changed

2 files changed

+20
-54
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Docusaurus to GitHub Pages
1+
name: Build Plugin and Deploy Example Site
22

33
on:
44
push:
@@ -9,8 +9,8 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
deploy:
13-
name: Deploy to GitHub Pages
12+
build_and_deploy:
13+
name: Build Plugin and Deploy Example
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout
@@ -23,13 +23,16 @@ jobs:
2323
cache: 'npm'
2424

2525
- name: Install root dependencies
26-
run: npm install
26+
run: npm ci
27+
28+
- name: Build plugin
29+
run: npm run build
2730

2831
- name: Install example dependencies
2932
run: npm install
3033
working-directory: ./example
3134

32-
- name: Build Docusaurus site
35+
- name: Build Docusaurus example site
3336
run: npm run build
3437
working-directory: ./example
3538

@@ -38,7 +41,15 @@ jobs:
3841
with:
3942
github_token: ${{ secrets.GITHUB_TOKEN }}
4043
publish_dir: ./example/build
41-
# The following lines are needed if you are deploying to a repository that is not the same as the one where the workflow is running.
42-
# For example, if you are deploying to a user page repository from an organization repository.
43-
# user_name: 'github-actions[bot]'
44-
# user_email: 'github-actions[bot]@users.noreply.github.com'
44+
45+
- name: Commit and push dist changes
46+
run: |
47+
git config --global user.name 'github-actions[bot]'
48+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
49+
git add dist
50+
if ! git diff --staged --quiet; then
51+
git commit -m "chore(build): Rebuild plugin [skip ci]"
52+
git push
53+
else
54+
echo "No changes in dist to commit."
55+
fi

0 commit comments

Comments
 (0)