-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (56 loc) · 1.74 KB
/
playground.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Run Playground Script and Deploy to gh-pages
on:
push:
branches:
- trunk
- wp-now-support
permissions:
contents: write # Ensure the workflow has write permissions
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Set up pnpm
uses: pnpm/[email protected]
with:
version: 8
- name: Ensure pnpm-lock.yaml exists
run: |
if [ ! -f pnpm-lock.yaml ]; then
echo "Error: pnpm-lock.yaml not found"
exit 1
fi
- name: Install dependencies with frozen lockfile
run: pnpm install --frozen-lockfile
- name: Run Playground Script
run: ./scripts/playground.sh
- name: Set up Git configuration
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Clone the gh-pages branch
run: |
git clone --single-branch --branch gh-pages https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
cd gh-pages
BRANCH_NAME=${GITHUB_REF_NAME}
if [ -d "$BRANCH_NAME" ]; then
rm -rf "$BRANCH_NAME"
fi
- name: Copy dist to branch directory
run: |
BRANCH_NAME=${GITHUB_REF_NAME}
mv dist gh-pages/$BRANCH_NAME
- name: Commit and push changes
run: |
cd gh-pages
git add .
git commit -m "Deploy to gh-pages branch from ${GITHUB_REF_NAME}"
git push origin gh-pages --force