-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add firebase hosting preview URLs
- Loading branch information
Showing
6 changed files
with
116 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"projects": { | ||
"default": "neuroglancer-demo" | ||
}, | ||
"targets": { | ||
"neuroglancer-demo": { | ||
"hosting": { | ||
"app": [ | ||
"neuroglancer" | ||
] | ||
} | ||
} | ||
}, | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,6 @@ jobs: | |
matrix: | ||
python-version: | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
node-version: | ||
- "20.x" | ||
|
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 preview | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
upload: | ||
strategy: | ||
matrix: | ||
node-version: | ||
- "20.x" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: | | ||
build_info="{'tag':'$(git describe --always --tags)', 'url':'https://github.com/google/neuroglancer/commit/$(git rev-parse HEAD)', 'timestamp':'$(date)'}" | ||
npm run build -- --define NEUROGLANCER_BUILD_INFO="${build_info}" | ||
- name: Upload client as artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: client | ||
path: | | ||
dist/min/* |
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,65 @@ | ||
name: Deploy preview | ||
|
||
on: | ||
workflow_run: | ||
worflows: ["Build preview"] | ||
types: [completed] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: client | ||
path: dist/min | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
run-id: "${{ context.payload.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 | ||
- uses: FirebaseExtended/action-hosting-deploy@v0 | ||
id: deploy | ||
with: | ||
repoToken: "${{ secrets.GITHUB_TOKEN }}" | ||
firebaseServiceAccount: "${{ secrets.FIREBASE_HOSTING_SERVICE_ACCOUNT_KEY }}" | ||
expires: 30d | ||
channel: "pr${{ steps.pr-id.outputs.pr-id }}" | ||
projectId: neuroglancer-demo | ||
- name: "Comment on PR" | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issueNumber = ${{ steps.pr-id.outputs.pr-id }}; | ||
const MESSAGE_START = "\n\n<!-- Firebase hosting preview start -->\n"; | ||
const MESSAGE_END = "\n<!-- Firebase hosting preview end -->\n"; | ||
const message = `---- | ||
🔥 Preview 🔥: ${{ steps.deploy.outputs.details_url }} | ||
Updated at ${Date.now()} for commit ${{ github.event.workflow_run.head_commit.id }} | ||
Expires: ${{ steps.deploy.outputs.expire_time }} | ||
`; | ||
const { data: pull } = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: issueNumber, | ||
}); | ||
let body = ""; | ||
if (pull.body && pull.body.includes(MESSAGE_SEPARATOR_START)) { | ||
body = pull.body.slice(0, pull.body.indexOf(MESSAGE_SEPARATOR_START)); | ||
body = body + MESSAGE_SEPARATOR_START + message + MESSAGE_SEPARATOR_END; | ||
body = body + pull.body.slice(pull.body.indexOf(MESSAGE_SEPARATOR_END) + MESSAGE_SEPARATOR_END.length); | ||
} else { | ||
body = MESSAGE_SEPARATOR_START + message + MESSAGE_SEPARATOR_END; | ||
} | ||
github.rest.pulls.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.issue.number, | ||
body: body, | ||
}); |
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 |
---|---|---|
|
@@ -20,3 +20,4 @@ tsconfig.tsbuildinfo | |
/ngauth_server/secrets/ | ||
.eslintcache | ||
/lib | ||
/.firebase |
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,6 @@ | ||
{ | ||
"hosting": { | ||
"target": "app", | ||
"public": "dist/min" | ||
} | ||
} |