diff --git a/.github/workflows/gitpage.yaml b/.github/workflows/cd.yaml similarity index 53% rename from .github/workflows/gitpage.yaml rename to .github/workflows/cd.yaml index 014957b..2be048a 100644 --- a/.github/workflows/gitpage.yaml +++ b/.github/workflows/cd.yaml @@ -29,4 +29,26 @@ jobs: git checkout -b gh-pages git add . git commit -m "gitpage by CI" - git push --force secure-origin gh-pages \ No newline at end of file + git push --force secure-origin gh-pages + firebase-hosting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: build + run: | + npm ci + npx ng add angular-cli-ghpages --skip-confirmation + npx ng build --base-href=/2024/ + - name: lint + run: npm run lint + - name: Deploy to Firebase Hosting + uses: FirebaseExtended/action-hosting-deploy@v0 + with: + entryPoint: "./" + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" + projectId: "${{ secrets.PROJECT_ID }}" + channelId: live \ No newline at end of file diff --git a/.github/workflows/preview-pull-request.yaml b/.github/workflows/preview-pull-request.yaml new file mode 100644 index 0000000..4c540cf --- /dev/null +++ b/.github/workflows/preview-pull-request.yaml @@ -0,0 +1,34 @@ +name: Deploy to Firebase Hosting on PR + +on: + pull_request: + branches: + - main + paths: + - '.github/workflows/preview-pull-request.yaml' + - '**' + +jobs: + deploy_web: + name: Web Firebase Hosting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: build + run: | + npm ci + npx ng add angular-cli-ghpages --skip-confirmation + npx ng build --base-href=/2024/ + - name: lint + run: npm run lint + - name: Deploy to Firebase + uses: FirebaseExtended/action-hosting-deploy@v0 + with: + entryPoint: "./" + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" + projectId: "${{ secrets.PROJECT_ID }}" + channelId: ${{ github.head_ref }} \ No newline at end of file diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..03bc724 --- /dev/null +++ b/firebase.json @@ -0,0 +1,19 @@ +{ + "hosting": [ + { + "site": "devfest-taipei-3cb0a", + "public": ".", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } + ] +} \ No newline at end of file