Skip to content

Commit 5245657

Browse files
committed
build website on PR, push on release
1 parent d4e4b81 commit 5245657

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ jobs:
447447

448448
- name: "Upload artifacts: scripts/res/apiDocs"
449449
id: upload-api-docs
450-
if: ${{ matrix.generate_api_docs && startsWith(github.ref, 'refs/tags/v') }}
450+
if: ${{ matrix.generate_api_docs }}
451451
uses: actions/upload-artifact@v4
452452
with:
453453
name: api-docs
@@ -492,39 +492,37 @@ jobs:
492492
repository: rescript-lang/rescript-lang.org
493493
token: ${{ secrets.GITHUB_TOKEN }}
494494

495-
- name: Set up Git config
496-
run: |
497-
git config --global user.name "github-actions[bot]"
498-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
499-
500-
- name: Authenticate GitHub CLI
501-
env:
502-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
503-
run: echo "$GH_TOKEN" | gh auth login --with-token
504-
505-
- name: create-new-branch
506-
run: git checkout -b sync-api-docs-${{ github.ref_name }}
507-
508495
- name: Download artifacts
509496
uses: actions/download-artifact@v4
510497
with:
511498
artifact-ids: ${{ needs.build-compiler.outputs.api-docs-artifact-id }}
512499
path: data/api
513500

501+
- name: Check if repo is clean
502+
id: diffcheck
503+
run: |
504+
if [ -z "$(git status --porcelain)" ]; then
505+
echo "clean=true" >> $GITHUB_OUTPUT
506+
else
507+
echo "clean=false" >> $GITHUB_OUTPUT
508+
fi
509+
510+
- name: Build website
511+
if: steps.diffcheck.outputs.clean == 'false'
512+
run: |
513+
npm ci
514+
npx rescript
515+
npm run build
516+
514517
- name: Commit and push
518+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
515519
run: |
520+
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
521+
git config --global user.name "github-actions[bot]"
522+
git config --global user.email "[email protected]"
516523
git add data/api
517524
git commit -m "Update API docs for ${{ github.ref_name }}"
518-
git push --set-upstream origin sync-api-docs-${{ github.ref_name }}
519-
520-
- name: Create Pull Request
521-
run: |
522-
cd repo-b
523-
gh pr create \
524-
--title "Sync API docs for ${{ github.ref_name }}" \
525-
--body "Sync API docs for ${{ github.ref_name }}. This PR was created via GitHub Actions using gh CLI." \
526-
--head sync-api-docs-${{ github.ref_name }} \
527-
--base master
525+
git push
528526
529527
test-integration:
530528
needs:

0 commit comments

Comments
 (0)