forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from lincbrain/ak-merge-upstream
Merge upstream, include GitHub Actions to deploy PRs to staging environment
- Loading branch information
Showing
114 changed files
with
34,534 additions
and
13,069 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,12 @@ | |
"hosting": { | ||
"app": [ | ||
"neuroglancer" | ||
], | ||
"docs": [ | ||
"neuroglancer-docs" | ||
] | ||
} | ||
} | ||
}, | ||
"etags": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build docs preview | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
- name: Setup Graphviz | ||
uses: ts-graphviz/setup-graphviz@b1de5da23ed0a6d14e0aeee8ed52fdd87af2363c # v2.0.2 | ||
with: | ||
macos-skip-brew-update: "true" | ||
- name: Install nox | ||
run: pip install nox | ||
- name: Build documentation | ||
run: nox -s docs | ||
- name: Upload client as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: docs | ||
path: | | ||
dist/docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Deploy docs preview | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build docs preview"] | ||
types: [completed] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: "Create commit status" | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const commitId = "${{ github.event.workflow_run.head_commit.id }}"; | ||
await github.rest.repos.createCommitStatus({ | ||
context: "docs-preview", | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: commitId, | ||
state: "pending", | ||
description: `Creating preview`, | ||
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | ||
}); | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: docs | ||
path: dist/docs | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
run-id: "${{ github.event.workflow_run.id }}" | ||
- name: Get PR ID | ||
# https://github.com/orgs/community/discussions/25220#discussioncomment-7532132 | ||
id: pr-id | ||
run: | | ||
PR_ID=$(gh run view -R ${{ github.repository }} ${{ github.event.workflow_run.id }} | grep -oP '#[0-9]+ . ${{ github.event.workflow_run.id }}' | grep -oP '#[0-9]+' | cut -c 2-) | ||
echo "pr-id=${PR_ID}" >> $GITHUB_OUTPUT | ||
env: | ||
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
- uses: FirebaseExtended/action-hosting-deploy@v0 | ||
id: deploy | ||
with: | ||
repoToken: "${{ secrets.GITHUB_TOKEN }}" | ||
firebaseServiceAccount: "${{ secrets.FIREBASE_HOSTING_SERVICE_ACCOUNT_KEY }}" | ||
expires: 30d | ||
channelId: "pr${{ steps.pr-id.outputs.pr-id }}" | ||
projectId: neuroglancer-demo | ||
target: docs | ||
- name: "Update commit status" | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const expires = new Date("${{ steps.deploy.outputs.expire_time }}"); | ||
const commitId = "${{ github.event.workflow_run.head_commit.id }}"; | ||
await github.rest.repos.createCommitStatus({ | ||
context: "docs-preview", | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: commitId, | ||
state: "success", | ||
target_url: "${{ steps.deploy.outputs.details_url }}", | ||
description: `Preview created, expires at: ${expires.toISOString()}`, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,47 @@ | ||
name: Deploy preview | ||
name: Build and Deploy Staging | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build preview"] | ||
types: [completed] | ||
push: | ||
branches: | ||
- staging | ||
- "**" | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: "Create commit status" | ||
uses: actions/github-script@v7 | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const commitId = "${{ github.event.workflow_run.head_commit.id }}"; | ||
await github.rest.repos.createCommitStatus({ | ||
context: "client-preview", | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: commitId, | ||
state: "pending", | ||
description: `Creating preview`, | ||
target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, | ||
}); | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: client | ||
path: dist/client | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
run-id: "${{ github.event.workflow_run.id }}" | ||
- name: Get PR ID | ||
# https://github.com/orgs/community/discussions/25220#discussioncomment-7532132 | ||
id: pr-id | ||
run: | | ||
PR_ID=$(gh run view -R ${{ github.repository }} ${{ github.event.workflow_run.id }} | grep -oP '#[0-9]+ . ${{ github.event.workflow_run.id }}' | grep -oP '#[0-9]+' | cut -c 2-) | ||
echo "pr-id=${PR_ID}" >> $GITHUB_OUTPUT | ||
env: | ||
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
- uses: FirebaseExtended/action-hosting-deploy@v0 | ||
id: deploy | ||
ref: ${{ github.event.inputs.commit_sha || github.sha }} | ||
|
||
- name: Set short sha name for sub-directory | ||
id: vars | ||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
- name: Check outputs | ||
run: echo ${{ steps.vars.outputs.sha_short }} | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
repoToken: "${{ secrets.GITHUB_TOKEN }}" | ||
firebaseServiceAccount: "${{ secrets.FIREBASE_HOSTING_SERVICE_ACCOUNT_KEY }}" | ||
expires: 30d | ||
channelId: "pr${{ steps.pr-id.outputs.pr-id }}" | ||
projectId: neuroglancer-demo | ||
- name: "Update commit status" | ||
uses: actions/github-script@v7 | ||
node-version: 20.x | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Build Project | ||
run: npm run build | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const expires = new Date("${{ steps.deploy.outputs.expire_time }}"); | ||
const commitId = "${{ github.event.workflow_run.head_commit.id }}"; | ||
await github.rest.repos.createCommitStatus({ | ||
context: "client-preview", | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
sha: commitId, | ||
state: "success", | ||
target_url: "${{ steps.deploy.outputs.details_url }}", | ||
description: `Preview created, expires at: ${expires.toISOString()}`, | ||
}); | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-2 | ||
|
||
- name: Upload to S3 | ||
run: | | ||
aws s3 sync dist/client/ ${{ secrets.CLOUDFRONT_DEPLOYMENT_LOCATION }}/staging/${{ steps.vars.outputs.sha_short }}/ --delete | ||
- name: Display URL for Neuroglancer | ||
run: echo "https://neuroglancer.lincbrain.org/cloudfront/frontend/staging/${{ steps.vars.outputs.sha_short }}/index.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ tsconfig.tsbuildinfo | |
.eslintcache | ||
/lib | ||
/.firebase | ||
.idea/ | ||
yarn.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
.parcel-cache | ||
dist | ||
/lib | ||
/docs/_build/ | ||
/.ruff_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.