Skip to content

Commit

Permalink
Merge pull request #152 from developmentseed/add/plausible-to-v1
Browse files Browse the repository at this point in the history
Add Plausible to v1
  • Loading branch information
vgeorge committed Mar 26, 2024
2 parents ecbf4c7 + ff94f99 commit acecc7c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 44 deletions.
48 changes: 6 additions & 42 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ name: Deploy
on:
push:
branches:
- 'develop'
- 'main'
- 'main'

env:
STAGING_STORAGE_ACCOUNT_NAME: lulcstagingfrontend
STAGING_CDN_PROFILE_NAME: lulc
STAGING_CDN_ENDPOINT: lulcstaging
STAGING_RESOURCE_GROUP: lulcterraformdev
PRODUCTION_STORAGE_ACCOUNT_NAME: lulctfproductionfrontend
PRODUCTION_CDN_PROFILE_NAME: lulctfproduction
PRODUCTION_CDN_ENDPOINT: lulctfproduction
Expand All @@ -26,12 +21,12 @@ jobs:

- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14

- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v2
Expand All @@ -44,64 +39,33 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install

- name: Post install (make sure local.js exists to avoid breaking config)
run: yarn postinstall

- name: Build Stage
if: github.ref == 'refs/heads/develop'
run: yarn stage

- name: Build Prod
if: github.ref == 'refs/heads/main'
run: yarn build

- name: Azure Login
if: github.ref == 'refs/heads/develop'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_STAGING }}

- name: Azure Login
if: github.ref == 'refs/heads/main'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS_PRODUCTION }}


- name: Upload to blob storage
if: github.ref == 'refs/heads/develop'
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch --account-name $STAGING_STORAGE_ACCOUNT_NAME --overwrite -d '$web' -s ./dist
- name: Upload to blob storage
if: github.ref == 'refs/heads/main'
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch --account-name $PRODUCTION_STORAGE_ACCOUNT_NAME --overwrite -d '$web' -s ./dist
- name: Purge CDN endpoint
if: github.ref == 'refs/heads/develop'
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge --content-paths "/*" --profile-name $STAGING_CDN_PROFILE_NAME --name $STAGING_CDN_ENDPOINT --resource-group $STAGING_RESOURCE_GROUP
az storage blob upload-batch --account-name $PRODUCTION_STORAGE_ACCOUNT_NAME --overwrite -d '$web' -s ./dist
- name: Purge CDN endpoint
if: github.ref == 'refs/heads/main'
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge --content-paths "/*" --profile-name $PRODUCTION_CDN_PROFILE_NAME --name $PRODUCTION_CDN_ENDPOINT --resource-group $PRODUCTION_RESOURCE_GROUP
- name: Azure Logout
run: az logout
run: az logout
1 change: 1 addition & 0 deletions app/assets/scripts/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
appLongTitle: 'Planetary Computer Land Cover Mapping',
appDescription:
'Microsoft Planetary Computer Land Use/Land Classification Mapping tool',
plausibleDomain: 'landcover.io',
restApiEndpoint: 'https://api.lulc-staging.ds.io',
websocketEndpoint: 'wss://socket.lulc-staging.ds.io',

Expand Down
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

<link rel='author' type='text/plain' href='humans.txt' />

<script defer data-domain="{{plausibleDomain}}" src="https://plausible.io/js/script.js"></script>


<style>
#welcome-banner {
Expand Down
11 changes: 9 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { compile: collecticonsCompile } = require('collecticons-processor');
const {
appTitle,
appDescription,
plausibleDomain,
} = require('./app/assets/scripts/config/base').default;

// /////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -79,8 +80,8 @@ function serve() {
replace: ''
},
{ match: /{{appTitle}}/g, replace: appTitle },
{ match: /{{appDescription}}/g, replace: appDescription }
]
{ match: /{{appDescription}}/g, replace: appDescription },
],
});

// watch for changes
Expand Down Expand Up @@ -241,6 +242,12 @@ function html() {
.pipe($.replace('{{baseurl}}', baseurl))
.pipe($.replace('{{appTitle}}', appTitle))
.pipe($.replace('{{appDescription}}', appDescription))
.pipe(
$.replace(
'{{plausibleDomain}}',
process.env.NODE_ENV === 'production' ? plausibleDomain : ''
)
)
.pipe(gulp.dest('dist'))
);
}
Expand Down

0 comments on commit acecc7c

Please sign in to comment.