Skip to content

Commit dd113f8

Browse files
committed
okay, i think I managed to get the local authentication working again (in dev server). gonna start trying to see if I can get the actual github actions workflow to do it too.
1 parent d6bc405 commit dd113f8

File tree

13 files changed

+593
-1927
lines changed

13 files changed

+593
-1927
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: ForestGEO Live Site Deployment Pipeline
5+
6+
on:
7+
push:
8+
branches:
9+
- 'forestgeo-app-*'
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-app-development:
14+
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
15+
runs-on: ubuntu-latest
16+
environment: development
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Node.js version
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '18.x'
25+
26+
- name: create env file (in frontend/ directory) -- development
27+
id: create-env-file-dev
28+
run: |
29+
touch frontend/.env
30+
echo AZURE_AD_CLIENT_SECRET=${{ secrets.AZURE_AD_CLIENT_SECRET }} >> frontend/.env
31+
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
32+
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
33+
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
34+
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
35+
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
36+
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
37+
echo AZURE_SQL_DATABASE=${{ secrets.AZURE_SQL_DATABASE }} >> frontend/.env
38+
echo AZURE_SQL_PORT=${{ secrets.AZURE_SQL_PORT }} >> frontend/.env
39+
echo AZURE_STORAGE_SAS_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_SAS_CONNECTION_STRING }} >> frontend/.env
40+
echo AZURE_SQL_SCHEMA=${{ secrets.AZURE_SQL_SCHEMA }} >> frontend/.env
41+
echo AZURE_SQL_CATALOG_SCHEMA=${{ secrets.AZURE_SQL_CATALOG_SCHEMA }} >> frontend/.env
42+
echo AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} >> frontend/.env
43+
echo NEXTAUTH_DEBUG=true >> frontend/.env
44+
echo NODE_ENV=development >> frontend/.env
45+
echo PORT=3000 >> frontend/.env
46+
echo FG_PAT=${{ secrets.FG_PAT }} >> frontend/.env
47+
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
48+
echo REPO=${{ secrets.REPO }} >> frontend/.env
49+
50+
- name: Cache node modules
51+
uses: actions/cache@v2
52+
with:
53+
path: frontend/node_modules
54+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
55+
restore-keys: |
56+
${{ runner.os }}-node-
57+
58+
- name: Cache Next.js build
59+
uses: actions/cache@v2
60+
with:
61+
path: frontend/.next/cache
62+
key: ${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/.next/cache') }}
63+
restore-keys: |
64+
${{ runner.os }}-next-
65+
${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}
66+
67+
- name: move into frontend --> npm install, build, and test
68+
run: |
69+
cd frontend/
70+
npm install
71+
npm run build
72+
npm run test --if-present
73+
74+
- name: Move directories into build/standalone to reduce app load
75+
run: |
76+
mv ./frontend/build/static ./frontend/build/standalone/build
77+
mv ./frontend/public ./frontend/build/standalone
78+
79+
- name: Upload build artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: app-build
83+
path: frontend/build/standalone
84+
85+
deploy-app-development:
86+
needs: build-app-development
87+
runs-on: ubuntu-latest
88+
environment: development
89+
90+
steps:
91+
- name: Download build artifact
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: app-build
95+
path: frontend/build/standalone
96+
97+
- name: 'Deploy to Azure Web App (development)'
98+
id: deploy-to-webapp-dev
99+
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
100+
uses: azure/webapps-deploy@v2
101+
with:
102+
app-name: 'forestgeo-livesite'
103+
slot-name: 'development'
104+
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_DEVELOPMENT }}
105+
package: frontend/build/standalone

.github/workflows/main-forestgeo-livesite.yml

+1-124
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,9 @@ on:
77
push:
88
branches:
99
- main
10-
- 'forestgeo-app-*'
1110
workflow_dispatch:
1211

1312
jobs:
14-
build-app-development:
15-
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
16-
runs-on: ubuntu-latest
17-
environment: development
18-
19-
steps:
20-
- uses: actions/checkout@v4
21-
22-
- name: Set up Node.js version
23-
uses: actions/setup-node@v3
24-
with:
25-
node-version: '18.x'
26-
27-
- name: create env file (in frontend/ directory) -- development
28-
id: create-env-file-dev
29-
run: |
30-
touch frontend/.env
31-
echo AZURE_AD_CLIENT_SECRET=${{ secrets.AZURE_AD_CLIENT_SECRET }} >> frontend/.env
32-
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
33-
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
34-
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
35-
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> frontend/.env
36-
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
37-
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
38-
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
39-
echo AZURE_SQL_DATABASE=${{ secrets.AZURE_SQL_DATABASE }} >> frontend/.env
40-
echo AZURE_SQL_PORT=${{ secrets.AZURE_SQL_PORT }} >> frontend/.env
41-
echo AZURE_STORAGE_SAS_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_SAS_CONNECTION_STRING }} >> frontend/.env
42-
echo AZURE_SQL_SCHEMA=${{ secrets.AZURE_SQL_SCHEMA }} >> frontend/.env
43-
echo AZURE_SQL_CATALOG_SCHEMA=${{ secrets.AZURE_SQL_CATALOG_SCHEMA }} >> frontend/.env
44-
echo AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} >> frontend/.env
45-
echo NEXTAUTH_DEBUG=true >> frontend/.env
46-
echo NODE_ENV=development >> frontend/.env
47-
echo PORT=3000 >> frontend/.env
48-
echo FG_PAT=${{ secrets.FG_PAT }} >> frontend/.env
49-
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
50-
echo REPO=${{ secrets.REPO }} >> frontend/.env
51-
52-
- name: Cache node modules
53-
uses: actions/cache@v2
54-
with:
55-
path: frontend/node_modules
56-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
57-
restore-keys: |
58-
${{ runner.os }}-node-
59-
60-
- name: Cache Next.js build
61-
uses: actions/cache@v2
62-
with:
63-
path: frontend/.next/cache
64-
key: ${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/.next/cache') }}
65-
restore-keys: |
66-
${{ runner.os }}-next-
67-
${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}
68-
69-
- name: move into frontend --> npm install, build, and test
70-
run: |
71-
cd frontend/
72-
npm install
73-
npm run build
74-
npm run test --if-present
75-
76-
- name: Move directories into build/standalone to reduce app load
77-
run: |
78-
mv ./frontend/build/static ./frontend/build/standalone/build
79-
mv ./frontend/public ./frontend/build/standalone
80-
81-
- name: Upload build artifact
82-
uses: actions/upload-artifact@v4
83-
with:
84-
name: app-build
85-
path: frontend/build/standalone
86-
8713
build-app-production:
8814
if: github.ref == 'refs/heads/main'
8915
runs-on: ubuntu-latest
@@ -105,7 +31,6 @@ jobs:
10531
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
10632
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
10733
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
108-
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> frontend/.env
10934
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
11035
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
11136
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
@@ -122,32 +47,6 @@ jobs:
12247
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
12348
echo REPO=${{ secrets.REPO }} >> frontend/.env
12449
125-
- name: create env file (in frontend/ directory) -- development
126-
id: create-env-file-dev
127-
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
128-
run: |
129-
touch frontend/.env
130-
echo AZURE_AD_CLIENT_SECRET=${{ secrets.AZURE_AD_CLIENT_SECRET }} >> frontend/.env
131-
echo AZURE_AD_CLIENT_ID=${{ secrets.AZURE_AD_CLIENT_ID }} >> frontend/.env
132-
echo AZURE_AD_TENANT_ID=${{ secrets.AZURE_AD_TENANT_ID }} >> frontend/.env
133-
echo NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} >> frontend/.env
134-
echo NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }} >> frontend/.env
135-
echo AZURE_SQL_USER=${{ secrets.AZURE_SQL_USER }} >> frontend/.env
136-
echo AZURE_SQL_PASSWORD=${{ secrets.AZURE_SQL_PASSWORD }} >> frontend/.env
137-
echo AZURE_SQL_SERVER=${{ secrets.AZURE_SQL_SERVER }} >> frontend/.env
138-
echo AZURE_SQL_DATABASE=${{ secrets.AZURE_SQL_DATABASE }} >> frontend/.env
139-
echo AZURE_SQL_PORT=${{ secrets.AZURE_SQL_PORT }} >> frontend/.env
140-
echo AZURE_STORAGE_SAS_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_SAS_CONNECTION_STRING }} >> frontend/.env
141-
echo AZURE_SQL_SCHEMA=${{ secrets.AZURE_SQL_SCHEMA }} >> frontend/.env
142-
echo AZURE_SQL_CATALOG_SCHEMA=${{ secrets.AZURE_SQL_CATALOG_SCHEMA }} >> frontend/.env
143-
echo AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} >> frontend/.env
144-
echo NEXTAUTH_DEBUG=true >> frontend/.env
145-
echo NODE_ENV=development >> frontend/.env
146-
echo PORT=3000 >> frontend/.env
147-
echo FG_PAT=${{ secrets.FG_PAT }} >> frontend/.env
148-
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
149-
echo REPO=${{ secrets.REPO }} >> frontend/.env
150-
15150
- name: Cache node modules
15251
uses: actions/cache@v2
15352
with:
@@ -203,26 +102,4 @@ jobs:
203102
app-name: 'forestgeo-livesite'
204103
slot-name: 'Production'
205104
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_PRODUCTION }}
206-
package: ./frontend/build/standalone
207-
208-
deploy-app-development:
209-
needs: build-app-development
210-
runs-on: ubuntu-latest
211-
environment: development
212-
213-
steps:
214-
- name: Download build artifact
215-
uses: actions/download-artifact@v4
216-
with:
217-
name: app-build
218-
path: frontend/build/standalone
219-
220-
- name: 'Deploy to Azure Web App (development)'
221-
id: deploy-to-webapp-dev
222-
if: startsWith(github.ref, 'refs/heads/forestgeo-app-')
223-
uses: azure/webapps-deploy@v2
224-
with:
225-
app-name: 'forestgeo-livesite'
226-
slot-name: 'development'
227-
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_DEVELOPMENT }}
228-
package: ./frontend/build/standalone
105+
package: frontend/build/standalone

frontend/app/api/auth/[[...nextauth]]/route.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { UserAuthRoles } from '@/config/macros';
55
import { SitesRDS } from '@/config/sqlrdsdefinitions/zones';
66

77
const handler = NextAuth({
8-
secret: process.env.NEXTAUTH_SECRET as string,
8+
secret: process.env.NEXTAUTH_SECRET!,
99
providers: [
1010
AzureADProvider({
1111
clientId: process.env.AZURE_AD_CLIENT_ID!,
1212
clientSecret: process.env.AZURE_AD_CLIENT_SECRET!,
13-
tenantId: process.env.AZURE_AD_CLIENT_ID!,
13+
tenantId: process.env.AZURE_AD_TENANT_ID!,
1414
authorization: { params: { scope: 'openid profile email user.Read' } }
1515
})
1616
],
@@ -20,6 +20,8 @@ const handler = NextAuth({
2020
},
2121
callbacks: {
2222
async signIn({ user, account, profile, email: signInEmail, credentials }) {
23+
console.log('callback -- signin');
24+
console.log('process envs: ', process.env);
2325
const azureProfile = profile as AzureADProfile;
2426
const userEmail = user.email || signInEmail || azureProfile.preferred_username;
2527
if (typeof userEmail !== 'string') {

frontend/app/api/hash/census/route.ts

-26
This file was deleted.

frontend/app/api/hash/plots/route.ts

-28
This file was deleted.

frontend/app/api/hash/quadrats/route.ts

-24
This file was deleted.

frontend/config/crypto-actions.ts

-5
This file was deleted.

frontend/config/utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'reflect-metadata';
21
import { PoolConnection } from 'mysql2/promise';
32
import { runQuery } from '@/components/processors/processormacros';
43

0 commit comments

Comments
 (0)