From 9a5f6a9b2f60ab71042168f5d7d5250224cc4416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 11:17:24 +0200 Subject: [PATCH 01/12] Delete .firebaserc --- .firebaserc | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .firebaserc diff --git a/.firebaserc b/.firebaserc deleted file mode 100644 index 6672b1ac..00000000 --- a/.firebaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "default": "hedwig-demo" - } -} From 8e001aed494829cef82b352b325a6872c29a7de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 11:52:26 +0200 Subject: [PATCH 02/12] test vitest workflow --- .github/workflows/vitest.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index dbb0b815..ab379c8c 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -1,6 +1,8 @@ name: "Test" on: + push: + branches: ["remove-firebaserc"] pull_request_target: branches: [main] @@ -43,6 +45,11 @@ jobs: key: ${{ runner.os }}-firebase-emulators-${{ github.sha }} restore-keys: | ${{ runner.os }}-firebase-emulators- + - name: Google Auth + id: auth + uses: 'google-github-actions/auth@v2' + with: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - uses: pnpm/action-setup@v3 with: version: 9 @@ -51,6 +58,8 @@ jobs: with: node-version: 20.x cache: "pnpm" + - run: pnpm install -g firebase-tools + - run: firebase use ${{ vars.PROJECT_ID }} - name: "Install Dependencies" run: pnpm i --frozen-lockfile - name: "Install Firebase" From b4706b83f291410f06c37e3597487c49bb82a097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 11:55:46 +0200 Subject: [PATCH 03/12] disabled pr checkout for test --- .github/workflows/vitest.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index ab379c8c..0884627c 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -26,18 +26,18 @@ jobs: contents: write steps: - - uses: actions/github-script@v7 - id: pr - with: - script: | - const { data: pullRequest } = await github.rest.pulls.get({ - ...context.repo, - pull_number: context.payload.pull_request.number, - }); - return pullRequest + #- uses: actions/github-script@v7 + # id: pr + # with: + # script: | + # const { data: pullRequest } = await github.rest.pulls.get({ + # ...context.repo, + # pull_number: context.payload.pull_request.number, + # }); + # return pullRequest - uses: actions/checkout@v4 - with: - ref: ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}} + # with: + # ref: ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}} - name: Cache firebase emulators uses: actions/cache@v4 with: From 8e36630b36e996d4e9fb2a34f179a3489aa70fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:04:32 +0200 Subject: [PATCH 04/12] use google application credential json --- .github/workflows/vitest.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 0884627c..a978b7d9 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -21,6 +21,7 @@ jobs: PUBLIC_FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} PUBLIC_FIREBASE_SERVICE_ACCOUNT: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} PUBLIC_FIREBASE_STORAGE_BUCKET: ${{secrets.FIREBASE_STORAGE_BUCKET}} + GOOGLE_APPLICATION_CREDENTIALS: google-application-credentials.json permissions: contents: write @@ -50,6 +51,10 @@ jobs: uses: 'google-github-actions/auth@v2' with: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' + - name: Prepare Google Application Credentials + shell: bash + run: | + echo "${{ secrets.GCP_CREDENTIALS }}" > "google-application-credentials.json" - uses: pnpm/action-setup@v3 with: version: 9 From 31d2181f3fe811961ea410348ba028703ff91a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:08:34 +0200 Subject: [PATCH 05/12] base64 --- .github/workflows/vitest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index a978b7d9..5f300eeb 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -54,7 +54,7 @@ jobs: - name: Prepare Google Application Credentials shell: bash run: | - echo "${{ secrets.GCP_CREDENTIALS }}" > "google-application-credentials.json" + echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 --decode > "google-application-credentials.json" - uses: pnpm/action-setup@v3 with: version: 9 From a65d7942000776afa7a4de3df2a279e5d4bed644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:15:51 +0200 Subject: [PATCH 06/12] remove credential file --- .github/workflows/vitest.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 5f300eeb..5f70d4d1 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -64,16 +64,18 @@ jobs: node-version: 20.x cache: "pnpm" - run: pnpm install -g firebase-tools - - run: firebase use ${{ vars.PROJECT_ID }} + - run: firebase use ${{ vars.PROJECT_ID }} --debug - name: "Install Dependencies" run: pnpm i --frozen-lockfile - name: "Install Firebase" run: pnpm install -g firebase-tools - name: "Test" run: pnpm run test - - name: "Upload Coverage" uses: actions/upload-artifact@v4 with: name: coverage path: coverage + - name: Remove credentials file + if: success() || failure() + run: rm credentials.json From bd842859c568810bfc016551b95638233ba3d307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:17:39 +0200 Subject: [PATCH 07/12] fix on remove credential file --- .github/workflows/vitest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 5f70d4d1..f6d3fd5d 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -64,7 +64,7 @@ jobs: node-version: 20.x cache: "pnpm" - run: pnpm install -g firebase-tools - - run: firebase use ${{ vars.PROJECT_ID }} --debug + - run: firebase use ${{ vars.PROJECT_ID }} - name: "Install Dependencies" run: pnpm i --frozen-lockfile - name: "Install Firebase" @@ -78,4 +78,4 @@ jobs: path: coverage - name: Remove credentials file if: success() || failure() - run: rm credentials.json + run: rm google-application-credentials.json From fe990f397b978a6cb6ed7e88dcbfcf25fa4c9a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:18:49 +0200 Subject: [PATCH 08/12] fix remove credentials file --- .github/workflows/vitest.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index f6d3fd5d..2cd89f45 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -76,6 +76,7 @@ jobs: with: name: coverage path: coverage - - name: Remove credentials file + - name: Remove credentials file if: success() || failure() - run: rm google-application-credentials.json + run: | + rm google-application-credentials.json From da8f5790176abdb165d70b3692e1f6c8ea11eb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:20:47 +0200 Subject: [PATCH 09/12] firebase debug mode --- .github/workflows/vitest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 2cd89f45..73b33407 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -64,7 +64,7 @@ jobs: node-version: 20.x cache: "pnpm" - run: pnpm install -g firebase-tools - - run: firebase use ${{ vars.PROJECT_ID }} + - run: firebase use ${{ vars.PROJECT_ID }} --debug - name: "Install Dependencies" run: pnpm i --frozen-lockfile - name: "Install Firebase" From c684a4fe1b8d86e7ce94e038abb9e08f2b87fc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:28:52 +0200 Subject: [PATCH 10/12] without base64 --- .github/workflows/vitest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 73b33407..f60f214b 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -54,7 +54,7 @@ jobs: - name: Prepare Google Application Credentials shell: bash run: | - echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 --decode > "google-application-credentials.json" + echo "${{ secrets.GOOGLE_APPLICATIONGCP_CREDENTIALS_CREDENTIALS }}" > "google-application-credentials.json" - uses: pnpm/action-setup@v3 with: version: 9 From fa7ac789e04074a13346feec5f93ac88caa835df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:29:11 +0200 Subject: [PATCH 11/12] fix without base64 --- .github/workflows/vitest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index f60f214b..38b3a8f0 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -54,7 +54,7 @@ jobs: - name: Prepare Google Application Credentials shell: bash run: | - echo "${{ secrets.GOOGLE_APPLICATIONGCP_CREDENTIALS_CREDENTIALS }}" > "google-application-credentials.json" + echo "${{ secrets.GCP_CREDENTIALS }}" > "google-application-credentials.json" - uses: pnpm/action-setup@v3 with: version: 9 From 4aa4b466e6e898a6797fe2ccaedf601c7ac449a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregorio=20Palam=C3=A0?= Date: Fri, 9 Aug 2024 12:35:43 +0200 Subject: [PATCH 12/12] updated login to firebase and removed .firebaserc --- .../workflows/deploy-firebase-functions.yml | 14 +++++++-- .github/workflows/test-firebase-functions.yml | 12 +++++++ .github/workflows/vitest.yml | 31 +++++++------------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-firebase-functions.yml b/.github/workflows/deploy-firebase-functions.yml index 109af2b2..c0dc58f1 100644 --- a/.github/workflows/deploy-firebase-functions.yml +++ b/.github/workflows/deploy-firebase-functions.yml @@ -12,6 +12,8 @@ jobs: id-token: 'write' runs-on: ubuntu-latest + env: + GOOGLE_APPLICATION_CREDENTIALS: google-application-credentials.json environment: demo steps: @@ -56,6 +58,14 @@ jobs: envkey_PUBLIC_FIREBASE_FUNCTIONS_REGION: ${{ vars.REGION }} file_name: .env - run: cd functions && pnpm run build + - name: Prepare Google Application Credentials + shell: bash + run: | + echo "${{ secrets.GCP_CREDENTIALS }}" > "google-application-credentials.json" - run: pnpm install -g firebase-tools - - run: firebase use ${{ vars.PROJECT_ID }} --token ${{ secrets.FIREBASE_TOKEN }} - - run: firebase deploy --only functions --token ${{ secrets.FIREBASE_TOKEN }} + - run: firebase use ${{ vars.PROJECT_ID }} + - run: firebase deploy --only functions + - name: Remove credentials file + if: success() || failure() + run: | + rm google-application-credentials.json diff --git a/.github/workflows/test-firebase-functions.yml b/.github/workflows/test-firebase-functions.yml index 8f00507b..178e63f3 100644 --- a/.github/workflows/test-firebase-functions.yml +++ b/.github/workflows/test-firebase-functions.yml @@ -16,6 +16,9 @@ jobs: needs: authorize timeout-minutes: 60 runs-on: ubuntu-latest + env: + GOOGLE_APPLICATION_CREDENTIALS: google-application-credentials.json + steps: - uses: actions/github-script@v7 id: pr @@ -58,7 +61,12 @@ jobs: restore-keys: | ${{ runner.os }}-pnpm-store- - run: cd functions && pnpm install --no-frozen-lockfile + - name: Prepare Google Application Credentials + shell: bash + run: | + echo "${{ secrets.GCP_CREDENTIALS }}" > "google-application-credentials.json" - run: pnpm install -g firebase-tools + - run: firebase use ${{ vars.PROJECT_ID }} - name: Make envfile for functions uses: SpicyPizza/create-envfile@v2.0 with: @@ -78,3 +86,7 @@ jobs: file_name: .env - run: cd functions && pnpm run build - run: cd functions && pnpm run test + - name: Remove credentials file + if: success() || failure() + run: | + rm google-application-credentials.json diff --git a/.github/workflows/vitest.yml b/.github/workflows/vitest.yml index 38b3a8f0..996f5dd6 100644 --- a/.github/workflows/vitest.yml +++ b/.github/workflows/vitest.yml @@ -1,8 +1,6 @@ name: "Test" on: - push: - branches: ["remove-firebaserc"] pull_request_target: branches: [main] @@ -27,18 +25,18 @@ jobs: contents: write steps: - #- uses: actions/github-script@v7 - # id: pr - # with: - # script: | - # const { data: pullRequest } = await github.rest.pulls.get({ - # ...context.repo, - # pull_number: context.payload.pull_request.number, - # }); - # return pullRequest + - uses: actions/github-script@v7 + id: pr + with: + script: | + const { data: pullRequest } = await github.rest.pulls.get({ + ...context.repo, + pull_number: context.payload.pull_request.number, + }); + return pullRequest - uses: actions/checkout@v4 - # with: - # ref: ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}} + with: + ref: ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}} - name: Cache firebase emulators uses: actions/cache@v4 with: @@ -46,11 +44,6 @@ jobs: key: ${{ runner.os }}-firebase-emulators-${{ github.sha }} restore-keys: | ${{ runner.os }}-firebase-emulators- - - name: Google Auth - id: auth - uses: 'google-github-actions/auth@v2' - with: - credentials_json: '${{ secrets.GCP_CREDENTIALS }}' - name: Prepare Google Application Credentials shell: bash run: | @@ -64,7 +57,7 @@ jobs: node-version: 20.x cache: "pnpm" - run: pnpm install -g firebase-tools - - run: firebase use ${{ vars.PROJECT_ID }} --debug + - run: firebase use ${{ vars.PROJECT_ID }} - name: "Install Dependencies" run: pnpm i --frozen-lockfile - name: "Install Firebase"