Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial code for Cloud Function #1

Merged
merged 45 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7f21269
Add initial cd.yml
navzam Aug 15, 2024
e8134a7
Add cd step to install firebase-tools
navzam Aug 15, 2024
50d5039
Add initial function and firebase files
navzam Aug 15, 2024
967eb98
Add cd steps to install, build, and deploy
navzam Aug 15, 2024
c27e801
Add cd step to auth to Google
navzam Aug 15, 2024
fca3383
Add cd step for debugging
navzam Aug 15, 2024
821985a
Add cd step for debugging
navzam Aug 15, 2024
81f755f
Add cd steps to debug OIDC token
navzam Aug 16, 2024
121fe21
Add cd permissions for id token
navzam Aug 16, 2024
baa81e8
Add cd steps to test auth
navzam Aug 16, 2024
d912878
Update cd to checkout repo to subdirectory
navzam Aug 16, 2024
effc88d
Add cd step to debug cred path
navzam Aug 16, 2024
2a825df
Enable more cd steps with new working dir
navzam Aug 16, 2024
b655456
Add cd steps to output dirs for debugging
navzam Aug 16, 2024
c5d32ea
Add cd step to deploy function
navzam Aug 16, 2024
4641640
Add project_id to cd step
navzam Aug 16, 2024
16b7fbe
Update cd and config to fix deployment issues
navzam Aug 16, 2024
f34c040
Set node version to 18 or higher
navzam Aug 16, 2024
0d1ed09
Update package-lock after node version change
navzam Aug 16, 2024
e6b174c
Add cd step to list firebase projects for debugging
navzam Aug 16, 2024
4d97bb6
Add cd step to debug auth
navzam Aug 16, 2024
e300ec3
Change node version back to 20
navzam Aug 16, 2024
9fc44b8
Run function every 5 mins for testing
navzam Aug 16, 2024
d2f6ddd
Set node version to minimum 18 again
navzam Aug 16, 2024
0ff07f4
Change back to node 20
navzam Aug 16, 2024
7f2e4fb
Add cd step to use node 20
navzam Aug 16, 2024
59a738d
Clean up cd
navzam Aug 16, 2024
146acf5
Update eslint config
navzam Aug 16, 2024
8ff4ad3
Update logging for debugging
navzam Aug 16, 2024
8d4e123
Update firebase-functions to v5
navzam Aug 16, 2024
c1bf7f5
Add debug flag for deploy
navzam Aug 16, 2024
934eea5
Update code to test artifact deletion permissions
navzam Aug 16, 2024
5372e09
Update firebase-admin package
navzam Aug 16, 2024
de885d3
Update firebase-functions-test package
navzam Aug 16, 2024
c2c2116
Update typescript package
navzam Aug 16, 2024
40283da
Use npm instead of yarn in predeploy
navzam Aug 16, 2024
232feb7
Code bump for debugging
navzam Aug 16, 2024
33dfb6e
Remove eslint rule for quotes
navzam Aug 16, 2024
ddbc30e
Update function code
navzam Aug 16, 2024
fb5c130
Remove noUnusedLocals in tsconfig
navzam Aug 16, 2024
be0a44c
Use firebase logger instead of console.log
navzam Aug 17, 2024
2a7d66b
Update eslint rules to match Simulator repo
navzam Aug 17, 2024
b54cf88
Update cd workflow for main branch
navzam Aug 17, 2024
d9381b2
Update schedule to only run every 1 hr
navzam Aug 17, 2024
96c8bb9
Update cleanup to use expiresAt field
navzam Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: [
"@typescript-eslint",
"import",
],
rules: {
// Project-specific ESLint rules
'array-bracket-spacing': 'error',
'arrow-spacing': 'error',
'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
'comma-style': 'error',
'eqeqeq': 'error',
'indent': ['error', 2, { 'SwitchCase': 1 }],
'keyword-spacing': 'error',
'newline-per-chained-call': 'error',
'no-confusing-arrow': 'error',
'no-duplicate-imports': 'error',
'no-else-return': 'error',
'no-new-wrappers': 'error',
'no-param-reassign': 'error',
'no-useless-constructor': 'error',
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': 'error',
'object-curly-spacing': ['error', 'always'],
'operator-linebreak': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'semi': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': ['error', { 'named': 'never' }],
'space-in-parens': 'error',
'space-infix-ops': 'error',
'spaced-comment': 'error',
'template-curly-spacing': 'error',

// Project-specific ESLint rules for TypeScript
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-module-boundary-types' : 'off',
'@typescript-eslint/no-floating-promises': ['error', { ignoreIIFE: true }],
'@typescript-eslint/no-unused-vars': ['off'],
},
};
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "kipr-321905"
}
}
48 changes: 48 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy to Google Cloud

on:
push:
branches: [ main ]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
# Needed to produce an OIDC token, which is used for Workload Identity Federation with Google Cloud
id-token: write
contents: read
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
path: checkout-prefix
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install firebase-tools
run: npm install -g firebase-tools
- name: Authenticate to Google
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER_ID }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_ADDRESS }}
create_credentials_file: true
export_environment_variables: true
cleanup_credentials: true
- name: Install dependencies
run: npm install
working-directory: checkout-prefix
- name: Build
run: npm run build
working-directory: checkout-prefix
- name: Deploy functions
id: deployFunctions
run: npm run deploy
working-directory: checkout-prefix
- name: Output firebase debug log on deployment failure
if: always() && (steps.deployFunctions.outcome == 'failure')
run: cat firebase-debug.log
working-directory: checkout-prefix
26 changes: 26 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "."
},
"emulators": {
"auth": {
"port": 9099
},
"firestore": {
"port": 8080
},
"ui": {
"enabled": true,
"port": 4001
},
"functions": {
"enabled": true,
"port": 5001
},
"singleProjectMode": true
}
}
Loading