Fix prod deployment cache issue and analytics templating

This commit is contained in:
Keavon Chambers 2023-08-12 13:16:49 -07:00
parent fd338c945f
commit cfe38c6413
3 changed files with 19 additions and 3 deletions

View file

@ -9,6 +9,7 @@ on:
- master
env:
CARGO_TERM_COLOR: always
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="dev.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script>
jobs:
build:
@ -44,6 +45,12 @@ jobs:
rustup update stable
rustc --version
- name: Replace template in <head> of index.html
run: |
# Remove the INDEX_HTML_HEAD_REPLACEMENT environment variable for build links (not master deploys)
git rev-parse --abbrev-ref HEAD | grep master > /dev/null || export INDEX_HTML_HEAD_REPLACEMENT=""
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
- name: 🌐 Build Graphite web code
env:
NODE_ENV: production
@ -58,8 +65,8 @@ jobs:
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: graphite-dev # e.g. 'my-project'
directory: frontend/dist # e.g. 'dist'
projectName: graphite-dev
directory: frontend/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: 👕 Lint Graphite web formatting

View file

@ -18,10 +18,14 @@ jobs:
RUSTC_WRAPPER: /usr/bin/sccache
CARGO_INCREMENTAL: 0
SCCACHE_DIR: /var/lib/github-actions/.cache
INDEX_HTML_HEAD_REPLACEMENT: <script defer data-domain="editor.graphite.rs" data-api="https://graphite.rs/visit/event" src="https://graphite.rs/visit/script.outbound-links.file-downloads.js"></script>
steps:
- uses: actions/checkout@v3
- name: 🔧 Clear wasm-bindgen cache
run: rm -r ~/.cache/.wasm-pack
- name: 🔧 Set up Node
uses: actions/setup-node@v3
with:
@ -38,6 +42,10 @@ jobs:
rustup update stable
rustc --version
- name: Replace template in <head> of index.html
run: |
sed -i "s|<!-- INDEX_HTML_HEAD_REPLACEMENT -->|$INDEX_HTML_HEAD_REPLACEMENT|" frontend/index.html
- name: 🌐 Build Graphite web code
env:
NODE_ENV: production
@ -53,4 +61,5 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: graphite-editor
directory: frontend/dist
branch: master
gitHubToken: ${{ secrets.GITHUB_TOKEN }}