Skip to content

Commit dd7612a

Browse files
authored
Merge pull request #1 from kipr/cd
Add initial code for Cloud Function
2 parents 5d8f3c5 + 96c8bb9 commit dd7612a

File tree

9 files changed

+8315
-0
lines changed

9 files changed

+8315
-0
lines changed

.eslintrc.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
node: true,
6+
},
7+
extends: [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
11+
],
12+
parser: "@typescript-eslint/parser",
13+
parserOptions: {
14+
project: ["tsconfig.json", "tsconfig.dev.json"],
15+
sourceType: "module",
16+
},
17+
ignorePatterns: [
18+
"/lib/**/*", // Ignore built files.
19+
],
20+
plugins: [
21+
"@typescript-eslint",
22+
"import",
23+
],
24+
rules: {
25+
// Project-specific ESLint rules
26+
'array-bracket-spacing': 'error',
27+
'arrow-spacing': 'error',
28+
'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
29+
'comma-style': 'error',
30+
'eqeqeq': 'error',
31+
'indent': ['error', 2, { 'SwitchCase': 1 }],
32+
'keyword-spacing': 'error',
33+
'newline-per-chained-call': 'error',
34+
'no-confusing-arrow': 'error',
35+
'no-duplicate-imports': 'error',
36+
'no-else-return': 'error',
37+
'no-new-wrappers': 'error',
38+
'no-param-reassign': 'error',
39+
'no-useless-constructor': 'error',
40+
'no-whitespace-before-property': 'error',
41+
'nonblock-statement-body-position': 'error',
42+
'object-curly-spacing': ['error', 'always'],
43+
'operator-linebreak': 'error',
44+
'prefer-arrow-callback': 'error',
45+
'prefer-const': 'error',
46+
'prefer-template': 'error',
47+
'semi': 'error',
48+
'space-before-blocks': 'error',
49+
'space-before-function-paren': ['error', { 'named': 'never' }],
50+
'space-in-parens': 'error',
51+
'space-infix-ops': 'error',
52+
'spaced-comment': 'error',
53+
'template-curly-spacing': 'error',
54+
55+
// Project-specific ESLint rules for TypeScript
56+
'@typescript-eslint/type-annotation-spacing': 'error',
57+
'@typescript-eslint/prefer-for-of': 'error',
58+
'@typescript-eslint/no-empty-interface': 'off',
59+
'@typescript-eslint/explicit-module-boundary-types' : 'off',
60+
'@typescript-eslint/no-floating-promises': ['error', { ignoreIIFE: true }],
61+
'@typescript-eslint/no-unused-vars': ['off'],
62+
},
63+
};

.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "kipr-321905"
4+
}
5+
}

.github/workflows/cd.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy to Google Cloud
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy
10+
runs-on: ubuntu-latest
11+
permissions:
12+
# Needed to produce an OIDC token, which is used for Workload Identity Federation with Google Cloud
13+
id-token: write
14+
contents: read
15+
steps:
16+
- name: Check out repo
17+
uses: actions/checkout@v4
18+
with:
19+
path: checkout-prefix
20+
- name: Use Node.js 20.x
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '20.x'
24+
- name: Install firebase-tools
25+
run: npm install -g firebase-tools
26+
- name: Authenticate to Google
27+
uses: 'google-github-actions/auth@v2'
28+
with:
29+
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER_ID }}
30+
project_id: ${{ secrets.GCP_PROJECT_ID }}
31+
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_ADDRESS }}
32+
create_credentials_file: true
33+
export_environment_variables: true
34+
cleanup_credentials: true
35+
- name: Install dependencies
36+
run: npm install
37+
working-directory: checkout-prefix
38+
- name: Build
39+
run: npm run build
40+
working-directory: checkout-prefix
41+
- name: Deploy functions
42+
id: deployFunctions
43+
run: npm run deploy
44+
working-directory: checkout-prefix
45+
- name: Output firebase debug log on deployment failure
46+
if: always() && (steps.deployFunctions.outcome == 'failure')
47+
run: cat firebase-debug.log
48+
working-directory: checkout-prefix

firebase.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"functions": {
3+
"predeploy": [
4+
"npm --prefix \"$RESOURCE_DIR\" run lint",
5+
"npm --prefix \"$RESOURCE_DIR\" run build"
6+
],
7+
"source": "."
8+
},
9+
"emulators": {
10+
"auth": {
11+
"port": 9099
12+
},
13+
"firestore": {
14+
"port": 8080
15+
},
16+
"ui": {
17+
"enabled": true,
18+
"port": 4001
19+
},
20+
"functions": {
21+
"enabled": true,
22+
"port": 5001
23+
},
24+
"singleProjectMode": true
25+
}
26+
}

0 commit comments

Comments
 (0)