From 81293c1822aa55a9059e19b715569d6d5c2e602b Mon Sep 17 00:00:00 2001 From: Clem Flory Date: Mon, 19 Feb 2024 02:19:27 -0600 Subject: [PATCH 1/4] fix github actions --- .github/workflows/firebase-hosting-pull-request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index b8891d1..30d83e6 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -7,6 +7,10 @@ jobs: build_and_preview: if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}" runs-on: ubuntu-latest + permissions: + checks: write + contents: read + pull-requests: write steps: - uses: actions/checkout@v4 - run: cd hosting && npm ci && node_modules/.bin/nx lint && node_modules/.bin/nx test && node_modules/.bin/nx build From 4038e53d56a15026890e7ae71e00b4e8df927927 Mon Sep 17 00:00:00 2001 From: Clem Flory Date: Mon, 19 Feb 2024 02:24:50 -0600 Subject: [PATCH 2/4] remove redundant steps --- .github/workflows/firebase-hosting-merge.yml | 3 ++- .github/workflows/firebase-hosting-pull-request.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 5ab59c2..966e294 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -11,7 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: cd hosting && npm ci && node_modules/.bin/nx build + # `nx test` and `nx build` are ran via Firebase, as a pre-deploy step + - run: cd hosting && npm ci - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 30d83e6..37340d7 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,7 +13,8 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 - - run: cd hosting && npm ci && node_modules/.bin/nx lint && node_modules/.bin/nx test && node_modules/.bin/nx build + # `nx test` and `nx build` are ran via Firebase, as a pre-deploy step + - run: cd hosting && npm ci && node_modules/.bin/nx lint - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: "${{ secrets.GITHUB_TOKEN }}" From b16ec35eb843f18f9b0f6cdf6b1c804c1cc9946e Mon Sep 17 00:00:00 2001 From: Clem Flory Date: Mon, 19 Feb 2024 02:29:52 -0600 Subject: [PATCH 3/4] move pre-req steps to github action --- .github/workflows/firebase-hosting-merge.yml | 2 +- .github/workflows/firebase-hosting-pull-request.yml | 6 ++++-- firebase.json | 7 +------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 966e294..6d0eeef 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # `nx test` and `nx build` are ran via Firebase, as a pre-deploy step - run: cd hosting && npm ci + - run: cd hosting && node_modules/.bin/nx build - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 37340d7..d8cf112 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,8 +13,10 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 - # `nx test` and `nx build` are ran via Firebase, as a pre-deploy step - - run: cd hosting && npm ci && node_modules/.bin/nx lint + - run: cd hosting && npm ci + - run: cd hosting && node_modules/.bin/nx lint + - run: cd hosting && node_modules/.bin/nx test + - run: cd hosting && node_modules/.bin/nx build - uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/firebase.json b/firebase.json index 87e822e..1a18415 100644 --- a/firebase.json +++ b/firebase.json @@ -1,13 +1,8 @@ { "hosting": { "target": "censeo", - "predeploy": "cd hosting && npm run test && npm run build", "public": "hosting/dist/censeo", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "headers": [ { "source": "*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)", From 7fbe2646453f01e123a913b53b6fe81ac71beef0 Mon Sep 17 00:00:00 2001 From: Clem Flory Date: Mon, 19 Feb 2024 02:35:41 -0600 Subject: [PATCH 4/4] use setup-node for npm caching --- .github/workflows/firebase-hosting-merge.yml | 5 +++++ .github/workflows/firebase-hosting-pull-request.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 6d0eeef..bd3fdad 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -11,6 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + cache-dependency-path: hosting/package-lock.json - run: cd hosting && npm ci - run: cd hosting && node_modules/.bin/nx build - uses: FirebaseExtended/action-hosting-deploy@v0 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index d8cf112..8beeefa 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -13,6 +13,11 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + cache-dependency-path: hosting/package-lock.json - run: cd hosting && npm ci - run: cd hosting && node_modules/.bin/nx lint - run: cd hosting && node_modules/.bin/nx test