Skip to content

first draft of deploy-dev-build workflow #1

first draft of deploy-dev-build workflow

first draft of deploy-dev-build workflow #1

name: Deploy dev build from PR

Check failure on line 1 in .github/workflows/deploy-dev-build.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy-dev-build.yml

Invalid workflow file

(Line: 51, Col: 19): Unrecognized named-value: 'variables'. Located at position 1 within expression: variables.DEV_DEPLOY_APP_ID
on:
workflow_run:
workflows: ["CI"] # ci.yml
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: Download Build Artifact
id: download-artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
continue-on-error: true
with:
name: plotly.node22.js # uploaded by ci.yml > publish-dist-node-v22
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: temp-dist
- name: Check if Artifact Exists
if: steps.download-artifact.outcome != 'success'
run: |
echo "No build artifact found for this run. Skipping deployment."
exit 0
- name: Prepare Folder Structure
id: prepare-folder-structure
run: |
PR_NUM="${{ github.event.workflow_run.pull_requests[0].number }}"
SHA="${{ github.event.workflow_run.head_sha }}"
mkdir -p "deploy/pr-$PR_NUM/$SHA"
mkdir -p "deploy/pr-$PR_NUM/latest"
# Name of file must match name of file uploaded by ci.yml > publish-dist-node-v22
cp temp-dist/plotly.node22.js "deploy/pr-$PR_NUM/$SHA/plotly.js"
cp temp-dist/plotly.node22.js "deploy/pr-$PR_NUM/latest/plotly.js"
echo "PR_NUM=$PR_NUM" >> $GITHUB_OUTPUT
echo "SHA=$SHA" >> $GITHUB_OUTPUT
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 #v3.1.1
with:
app-id: ${{ variables.DEV_DEPLOY_APP_ID }}
private-key: ${{ secrets.DEV_DEPLOY_APP_PRIVATE_KEY }}
owner: plotly
repositories: plotly.js-dev-builds
- name: Deploy to plotly.js-dev-builds repo
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
with:
repository-name: plotly/plotly.js-dev-builds
token: ${{ steps.generate-token.outputs.token }} # create-github-app-token action automatically outputs the token
branch: gh-pages
folder: deploy
target-folder: .
clean: false
- name: Generate Summary
run: |
BASE="https://plotly.github.io/plotly.js-dev-builds/pr-${{ steps.prepare-folder-structure.outputs.PR_NUM }}"
echo "### PR Build Deployed" >> $GITHUB_STEP_SUMMARY
echo "Builds for PR #${{ steps.prepare-folder-structure.outputs.PR_NUM }} are available:" >> $GITHUB_STEP_SUMMARY
echo "- [Latest for PR]($BASE/latest/plotly.js)" >> $GITHUB_STEP_SUMMARY
echo "- [Immutable (this commit)]($BASE/${{ steps.prepare-folder-structure.outputs.SHA }}/plotly.js)" >> $GITHUB_STEP_SUMMARY