Build and Deploy dashboard #231
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
name: Build and Deploy dashboard | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
schedule: | |
- cron: '0 8 * * *' | |
jobs: | |
big_query_update: | |
runs-on: ubuntu-latest | |
timeout-minutes: 300 | |
permissions: | |
contents: 'write' | |
id-token: 'write' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: create service-secrets.json | |
run: | | |
echo "$SERVICE_SECRETS" > service-secrets.json | |
env: | |
SERVICE_SECRETS: ${{ secrets.SERVICE_SECRETS }} | |
- name: Install dependencies | |
run: | | |
uv sync | |
- name: Build the dashboard | |
run: | | |
uv run traceback-with-variables napari_dashboard.big_query_update dashboard.db | |
env: | |
PEPY_KEY: ${{ secrets.PEPY_KEY }} | |
GH_TOKEN_: ${{ secrets.GITHUB_TOKEN }} | |
GOOGLE_APPLICATION_CREDENTIALS: service-secrets.json | |
ZULIP_API_KEY: ${{ secrets.ZULIP_API_KEY }} | |
# I'm using GH_TOKEN_ because using GITHUB_TOKEN during development crash gh app | |
- name: Set zulip message | |
if: ${{ always() }} | |
id: set_zulip_message | |
run: | | |
if [ "${{ job.status }}" == "success" ]; then | |
echo "MESSAGE=Google big query finished successful" >> $GITHUB_ENV | |
else | |
echo "MESSAGE=Google big query failed" >> $GITHUB_ENV | |
fi | |
- name: Send a stream message | |
if: ${{ always()}} | |
uses: zulip/github-actions-zulip/send-message@v1 | |
with: | |
api-key: ${{ secrets.ZULIP_API_KEY }} | |
email: "[email protected]" | |
organization-url: "https://napari.zulipchat.com" | |
to: "metrics and analytics" | |
type: "stream" | |
topic: "Google big query download" | |
content: ${{ env.MESSAGE }} | |
fetch_api_data: | |
needs: big_query_update | |
runs-on: ubuntu-latest | |
timeout-minutes: 300 | |
permissions: | |
contents: 'write' | |
id-token: 'write' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: create service-secrets.json | |
run: | | |
echo "$SERVICE_SECRETS" > service-secrets.json | |
env: | |
SERVICE_SECRETS: ${{ secrets.SERVICE_SECRETS }} | |
- name: Install dependencies | |
run: | | |
uv sync | |
- name: Update db from api | |
run: | | |
uv run traceback-with-variables napari_dashboard.api_update | |
env: | |
PEPY_KEY: ${{ secrets.PEPY_KEY }} | |
GH_TOKEN_: ${{ secrets.GITHUB_TOKEN }} | |
# I'm using GH_TOKEN_ because using GITHUB_TOKEN during development crash gh app | |
- name: Set zulip message | |
if: ${{ always() }} | |
id: set_zulip_message | |
run: | | |
if [ "${{ job.status }}" == "success" ]; then | |
echo "MESSAGE=API update successfully" >> $GITHUB_ENV | |
else | |
echo "MESSAGE=API update failed" >> $GITHUB_ENV | |
fi | |
- name: Send a stream message | |
if: ${{ always()}} | |
uses: zulip/github-actions-zulip/send-message@v1 | |
with: | |
api-key: ${{ secrets.ZULIP_API_KEY }} | |
email: "[email protected]" | |
organization-url: "https://napari.zulipchat.com" | |
to: "metrics and analytics" | |
type: "stream" | |
topic: "Deploy dashboard" | |
content: ${{ env.MESSAGE }} | |
update_webpage: | |
needs: fetch_api_data | |
runs-on: ubuntu-latest | |
timeout-minutes: 300 | |
permissions: | |
contents: 'write' | |
id-token: 'write' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: create service-secrets.json | |
run: | | |
echo "$SERVICE_SECRETS" > service-secrets.json | |
env: | |
SERVICE_SECRETS: ${{ secrets.SERVICE_SECRETS }} | |
- name: Install dependencies | |
run: | | |
uv sync | |
- name: Build the dashboard | |
run: | | |
uv run traceback-with-variables napari_dashboard.webpage_update | |
env: | |
PEPY_KEY: ${{ secrets.PEPY_KEY }} | |
GH_TOKEN_: ${{ secrets.GITHUB_TOKEN }} | |
# I'm using GH_TOKEN_ because using GITHUB_TOKEN during development crash gh app | |
- name: Deploy Dashboard | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./webpage | |
publish_branch: gh_pages | |
exclude_assets: 'napari_dashboard.xlsx' | |
- name: Set zulip message | |
if: ${{ always() }} | |
id: set_zulip_message | |
run: | | |
if [ "${{ job.status }}" == "success" ]; then | |
echo "MESSAGE=Dashboard deployed successfully" >> $GITHUB_ENV | |
else | |
echo "MESSAGE=Dashboard deployment failed" >> $GITHUB_ENV | |
fi | |
- name: Send a stream message | |
if: ${{ always()}} | |
uses: zulip/github-actions-zulip/send-message@v1 | |
with: | |
api-key: ${{ secrets.ZULIP_API_KEY }} | |
email: "[email protected]" | |
organization-url: "https://napari.zulipchat.com" | |
to: "metrics and analytics" | |
type: "stream" | |
topic: "Deploy dashboard" | |
content: ${{ env.MESSAGE }} |