mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
89 lines
2.4 KiB
YAML
89 lines
2.4 KiB
YAML
name: Deploy visualizer to GitHub Pages
|
|
|
|
on:
|
|
push:
|
|
branches: [data]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: pages
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
|
|
steps:
|
|
- name: Checkout data branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: data
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Pages
|
|
uses: actions/configure-pages@v4
|
|
|
|
# Make sku_links.json available to the static site without committing a second copy.
|
|
- name: Stage sku_links.json into site artifact
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p viz/data
|
|
if [[ -f data/sku_links.json ]]; then
|
|
cp -f data/sku_links.json viz/data/sku_links.json
|
|
else
|
|
# keep site functional even if file is missing
|
|
cat > viz/data/sku_links.json <<'EOF'
|
|
{
|
|
"generatedAt": "",
|
|
"links": [],
|
|
"ignores": []
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
- name: Upload site artifact
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: viz
|
|
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v4
|
|
|
|
- name: Build email alert (HTML)
|
|
id: alert
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
node tools/build_email_alert.js
|
|
echo "should_send=$(cat reports/alert_should_send.txt | tr -d '\r\n')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Debug alert outputs
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
echo "alert_should_send=$(cat reports/alert_should_send.txt || true)"
|
|
echo "subject=$(cat reports/alert_subject.txt || true)"
|
|
|
|
- name: Send email alert
|
|
if: steps.alert.outputs.should_send == '1'
|
|
uses: dawidd6/action-send-mail@v7
|
|
with:
|
|
server_address: smtp.gmail.com
|
|
server_port: 465
|
|
secure: true
|
|
username: ${{ secrets.MAIL_USERNAME }}
|
|
password: ${{ secrets.MAIL_PASSWORD }}
|
|
subject: file://reports/alert_subject.txt
|
|
to: brennan@codexwilkes.com, nathan.wilkes@codexwilkes.com
|
|
from: Spirit Tracker <${{ secrets.MAIL_USERNAME }}>
|
|
html_body: file://reports/alert.html
|