Skip to content

Commit 3cee66d

Browse files
authored
Merge pull request #89 from DataFlowAnalysis/editor-staging
2 parents ee6e5df + fb1c12f commit 3cee66d

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy to Staging
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
8+
issue_comment:
9+
types: [created]
10+
11+
jobs:
12+
build:
13+
# Run normally for push & workflow_dispatch
14+
# OR only when someone comments /stage on a PR
15+
if: >
16+
github.event_name != 'issue_comment' ||
17+
(
18+
github.event.issue.pull_request &&
19+
contains(github.event.comment.body, '/stage')
20+
)
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
with:
26+
persist-credentials: false
27+
28+
- name: Switch to PR branch
29+
if: github.event.issue.pull_request
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.XDECAF_EDITOR_STAGING }}
32+
run: gh pr checkout ${{ github.event.issue.number }}
33+
34+
- uses: actions/setup-node@v6
35+
with:
36+
node-version: "lts/*"
37+
38+
- name: Extract branch name
39+
shell: bash
40+
run: |
41+
if [[ "$${{ github.event_name }}" == 'workflow_dispatch' ]]; then
42+
echo "folder=branches/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
43+
elif [[ "${{ github.event_name }}" == "push" ]]; then
44+
echo "folder=tags/${GITHUB_REF#refs/tags/}" | sed 's/\./_/g' >> $GITHUB_OUTPUT
45+
elif [[ "${{ github.event_name }}" == "issue_comment" ]]; then
46+
echo "folder=prs/${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
47+
else
48+
echo "folder=not_found" >> $GITHUB_OUTPUT
49+
fi
50+
id: extract_folder_name
51+
52+
- name: Install and Build
53+
working-directory: frontend/webEditor
54+
run: |
55+
npm i
56+
npx vite build --base=/OnlineEditorStaging/${{ steps.extract_folder_name.outputs.folder }}/
57+
58+
- name: Deploy
59+
uses: JamesIves/github-pages-deploy-action@v4.8.0
60+
with:
61+
branch: gh-pages
62+
repository-name: DataFlowAnalysis/OnlineEditorStaging
63+
folder: ./frontend/webEditor/dist
64+
target-folder: ${{ steps.extract_folder_name.outputs.folder }}
65+
token: ${{ secrets.XDECAF_EDITOR_STAGING }}
66+
clean: true
67+
single-commit: false

0 commit comments

Comments
 (0)