Skip to content

Commit

Permalink
Merge pull request #1 from kipr/cd
Browse files Browse the repository at this point in the history
Add initial code for Cloud Function
  • Loading branch information
tcorbly authored Oct 29, 2024
2 parents 5d8f3c5 + 96c8bb9 commit dd7612a
Show file tree
Hide file tree
Showing 9 changed files with 8,315 additions and 0 deletions.
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

0 comments on commit dd7612a

Please sign in to comment.