Skip to content

Add workflow for uploading dev builds of Plotly.js #7795

Open
emilykl wants to merge 1 commit intomasterfrom
persistent-dev-build-url-2
Open

Add workflow for uploading dev builds of Plotly.js #7795
emilykl wants to merge 1 commit intomasterfrom
persistent-dev-build-url-2

Conversation

@emilykl
Copy link
Copy Markdown
Contributor

@emilykl emilykl commented May 5, 2026

Closes #7759

  • Add new upload-dev-build.yml workflow which uploads a development build of plotly.js every time a new commit is pushed to a PR
  • Builds are uploaded to a private repo and made available via GitHub Pages at the following URLs:
    • https://plotly.github.io/plotly.js-dev-builds/upload/pr-{PR_NUM}/latest/plotly.min.js (for the latest commit on a PR)
    • https://plotly.github.io/plotly.js-dev-builds/upload/pr-{PR_NUM}/{SHA}/plotly.min.js (for a specific commit SHA on a PR)
    • */plotly.js and */plot-schema.json also work
  • Also split publish-dist jobs into a separate publish-dist.yml workflow, so that the upload-dev-build workflow can be triggered as soon as publish-dist finishes, without waiting for all the tests to complete

Steps for testing

  • Note: The workflow_run trigger always runs the version of the workflow on the default branch. This is an important security feature, but it means workflow_run won't allow us to test this implementation
  • Instead, manually trigger this workflow using the "Run workflow" button on this page
    • Select Branch: persistent-dev-build-url-2 (this branch)
    • Enter PR number 7795 (this PR) and Run ID 25395337702 (a completed run of the publish-dist workflow for this PR)
  • Wait for the run to complete. After it finishes, on the run page you should see an output containing the links. Here's an example from a previous run. It will take about 2-3 minutes for the GitHub Pages deployment to finish before the links become functional.
Screenshot 2026-05-05 at 2 46 36 PM

@emilykl emilykl requested a review from camdecoster May 5, 2026 18:47
@emilykl
Copy link
Copy Markdown
Contributor Author

emilykl commented May 5, 2026

@camdecoster FYI there are no major changes to the contents of the publish-dist workflow steps.

@@ -1,17 +1,117 @@
name: Upload dev build from PR (placeholder, not yet implemented)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Upload dev build from PR

NODE_VERSION: '18'

jobs:
publish-dist:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine these two steps in a matrix configuration. They use (mostly) the same code.

echo "No build artifact found for $RUN_ID. Skipping upload."
exit 0

- name: Setup metadata and prepare folders
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and all subsequent steps get skipped if the download artifact step fails?

echo "### PR Build Uploaded" >> $GITHUB_STEP_SUMMARY
echo "Builds for PR #${{ steps.setup-metadata.outputs.PR_NUM }} are available:" >> $GITHUB_STEP_SUMMARY
echo "- Latest build for this PR: [$BASE/latest/plotly.min.js]($BASE/latest/plotly.min.js)" >> $GITHUB_STEP_SUMMARY
echo "- Build for this commit (permalink): [$BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js]($BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js)" >> $GITHUB_STEP_SUMMARY
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll be deleting these after a while, so let's not use the word "permalink".

Suggested change
echo "- Build for this commit (permalink): [$BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js]($BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js)" >> $GITHUB_STEP_SUMMARY
echo "- Build for this commit: [$BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js]($BASE/${{ steps.setup-metadata.outputs.SHA }}/plotly.min.js)" >> $GITHUB_STEP_SUMMARY

fi

echo "Using SHA: $SHA"
mkdir -p "upload/pr-$PR_NUM/$SHA"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include a metadata file that includes a timestamp inside the "pr-XXXX" folder to aid in eventually deleting old builds?

Comment on lines +37 to +46
- name: Preview CHANGELOG for next release (only on master)
if: github.ref == 'refs/heads/master'
run: npm run use-draftlogs && git --no-pager diff --color-words CHANGELOG.md || true

- name: Set draft version in package.json
run: |
node --eval "var fs = require('fs'); var inOut = './package.json'; var data = JSON.parse(fs.readFileSync(inOut)); var a = process.argv; data.version = a[a.length - 1].replace('v', ''); fs.writeFileSync(inOut, JSON.stringify(data, null, 2) + '\n');" $(git describe)

- name: View package.json diff between previous and next releases
run: git --no-pager diff --color-words tags/$(git describe --tags --abbrev=0) package.json || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need these steps anymore? I migrated them over, but I don't think they're necessary.

Comment on lines +17 to +18
env:
NODE_VERSION: '18'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
env:
NODE_VERSION: '18'


- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_VERSION }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you combine steps, this would become moot.

Suggested change
node-version: ${{ env.NODE_VERSION }}
node-version: 18

runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request')
(github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Create long lived direct links to PR versions of library

2 participants