Skip to content

Commit

Permalink
feat: merge branch 'develop' into deployments/staging/makerdao
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed Sep 19, 2024
2 parents 4c6b382 + 92d01fa commit fa7c6ef
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/create-and-publish-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Create and publish a Docker image

on:
push:
branches: ['develop', 'staging', 'main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# [1.0.0-dev.124](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.123...v1.0.0-dev.124) (2024-09-19)


### Features

* added robots.txt ([a735a79](https://github.com/powerhouse-inc/document-model-electron/commit/a735a79eba27f1ac51c243ee0471879c31d45784))

# [1.0.0-dev.123](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.122...v1.0.0-dev.123) (2024-09-19)


### Features

* avoid refreshing if already on latest app version ([e4c753d](https://github.com/powerhouse-inc/document-model-electron/commit/e4c753d09da69920aa7571d4908e50738d0fa7f7))

# [1.0.0-dev.122](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.121...v1.0.0-dev.122) (2024-09-19)


### Bug Fixes

* windows cookies scroll ([13a184d](https://github.com/powerhouse-inc/document-model-electron/commit/13a184d6cee1d63e17dd49725227ef16544acf90))

# [1.0.0-dev.121](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.120...v1.0.0-dev.121) (2024-09-18)


Expand Down
7 changes: 7 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ server {
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
}

location ${BASE_PATH}/robots.txt {
alias /usr/share/nginx/html/robots.txt;
expires 1w;
access_log off;
add_header Cache-Control "public";
}

location ${BASE_PATH} {
root /usr/share/nginx/html;
index index.html;
Expand Down
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /
Allow: /d/*
6 changes: 4 additions & 2 deletions src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ _self.addEventListener('activate', (event: ExtendableEvent) => {

export type NEW_VERSION_AVAILABLE_MESSAGE = {
type: 'NEW_VERSION_AVAILABLE';
version: string;
requiresHardRefresh: boolean;
};

Expand Down Expand Up @@ -56,19 +57,20 @@ async function checkAppVersion(version: string, requiresHardRefresh: boolean) {
await cache.put(VERSION_KEY, new Response(version));

// Update clients
await updateClients(requiresHardRefresh);
await updateClients(version, requiresHardRefresh);
}
} catch (error) {
console.error('Error checking version:', error);
}
}

async function updateClients(requiresHardRefresh: boolean) {
async function updateClients(version: string, requiresHardRefresh: boolean) {
await _self.clients.claim();
const clients = await _self.clients.matchAll();
clients.forEach(client => {
postMessage(client, {
type: 'NEW_VERSION_AVAILABLE',
version,
requiresHardRefresh,
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/utils/registerServiceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ class ServiceWorkerManager {
'type' in event.data ? (event as ServiceWorkerMessage) : null;
switch (message?.data.type) {
case 'NEW_VERSION_AVAILABLE': {
if (message.data.version === connectConfig.appVersion) {
return;
}
if (message.data.requiresHardRefresh) {
if (this.debug) {
console.log('New version available');
}

window.location.reload(); // Reload the page to load the new version
}
break;
Expand Down

0 comments on commit fa7c6ef

Please sign in to comment.