Skip to content

Commit 8f9ba66

Browse files
committed
first draft of deploy-dev-build workflow
1 parent 110c533 commit 8f9ba66

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ jobs:
668668
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
669669
name: Upload uncompressed plotly.js built from PR, using Node 22
670670
with:
671+
name: plotly.node22.js
671672
retention-days: 30
672673
archive: false
673674
path: dist/plotly.node22.js
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy dev build from PR
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"] # ci.yml
6+
types:
7+
- completed
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
if: github.event.workflow_run.event == 'pull_request'
13+
14+
steps:
15+
- name: Download Build Artifact
16+
id: download-artifact
17+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
18+
continue-on-error: true
19+
with:
20+
name: plotly.node22.js # uploaded by ci.yml > publish-dist-node-v22
21+
run-id: ${{ github.event.workflow_run.id }}
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
path: temp-dist
24+
25+
- name: Check if Artifact Exists
26+
if: steps.download-artifact.outcome != 'success'
27+
run: |
28+
echo "No build artifact found for this run. Skipping deployment."
29+
exit 0
30+
31+
- name: Prepare Folder Structure
32+
id: prepare-folder-structure
33+
run: |
34+
PR_NUM="${{ github.event.workflow_run.pull_requests[0].number }}"
35+
SHA="${{ github.event.workflow_run.head_sha }}"
36+
37+
mkdir -p "deploy/pr-$PR_NUM/$SHA"
38+
mkdir -p "deploy/pr-$PR_NUM/latest"
39+
40+
# Name of file must match name of file uploaded by ci.yml > publish-dist-node-v22
41+
cp temp-dist/plotly.node22.js "deploy/pr-$PR_NUM/$SHA/plotly.js"
42+
cp temp-dist/plotly.node22.js "deploy/pr-$PR_NUM/latest/plotly.js"
43+
44+
echo "PR_NUM=$PR_NUM" >> $GITHUB_OUTPUT
45+
echo "SHA=$SHA" >> $GITHUB_OUTPUT
46+
47+
- name: Generate GitHub App Token
48+
id: generate-token
49+
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 #v3.1.1
50+
with:
51+
app-id: ${{ variables.DEV_DEPLOY_APP_ID }}
52+
private-key: ${{ secrets.DEV_DEPLOY_APP_PRIVATE_KEY }}
53+
owner: plotly
54+
repositories: plotly.js-dev-builds
55+
56+
- name: Deploy to plotly.js-dev-builds repo
57+
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
58+
with:
59+
repository-name: plotly/plotly.js-dev-builds
60+
token: ${{ steps.generate-token.outputs.token }} # create-github-app-token action automatically outputs the token
61+
branch: gh-pages
62+
folder: deploy
63+
target-folder: .
64+
clean: false
65+
66+
- name: Generate Summary
67+
run: |
68+
BASE="https://plotly.github.io/plotly.js-dev-builds/pr-${{ steps.prepare-folder-structure.outputs.PR_NUM }}"
69+
echo "### PR Build Deployed" >> $GITHUB_STEP_SUMMARY
70+
echo "Builds for PR #${{ steps.prepare-folder-structure.outputs.PR_NUM }} are available:" >> $GITHUB_STEP_SUMMARY
71+
echo "- [Latest for PR]($BASE/latest/plotly.js)" >> $GITHUB_STEP_SUMMARY
72+
echo "- [Immutable (this commit)]($BASE/${{ steps.prepare-folder-structure.outputs.SHA }}/plotly.js)" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)