From d83b41a4fdf8c60166a1850d31a5badcd36b293f Mon Sep 17 00:00:00 2001 From: Peter Olds Date: Mon, 8 Jan 2024 22:16:11 -0800 Subject: [PATCH 1/3] feat: setup auto-deployment --- .firebaserc | 5 ++++ .github/workflows/firebase-hosting-merge.yml | 27 +++++++++++++++++++ .../firebase-hosting-pull-request.yml | 24 +++++++++++++++++ firebase.json | 16 +++++++++++ 4 files changed, 72 insertions(+) create mode 100644 .firebaserc create mode 100644 .github/workflows/firebase-hosting-merge.yml create mode 100644 .github/workflows/firebase-hosting-pull-request.yml create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..957c345 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "expr-playground" + } +} diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..8d48737 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -0,0 +1,27 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on merge +'on': + push: + branches: + - main +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version: '>=1.21.0' + cache: true + + - run: make build + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_EXPR_PLAYGROUND }}' + channelId: live + projectId: expr-playground diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..81f5939 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -0,0 +1,24 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + +name: Deploy to Firebase Hosting on PR +'on': pull_request +jobs: + build_and_preview: + if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version: '>=1.21.0' + cache: true + + - run: make build + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_EXPR_PLAYGROUND }}' + projectId: expr-playground diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..b9c1ce9 --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "web", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} From a48795a3642fc36d247388dd6281f67a47427a05 Mon Sep 17 00:00:00 2001 From: Peter Olds Date: Mon, 8 Jan 2024 22:19:33 -0800 Subject: [PATCH 2/3] ignore the firebase cache --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 331ddc5..3e6456b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ bin/ *.out web/main.wasm web/assets/main.wasm.gz -web/assets/data.json \ No newline at end of file +web/assets/data.json +/.firebase From 97f2433f9bfa370a5beb4fc20cb1f96631ac245d Mon Sep 17 00:00:00 2001 From: Peter Olds Date: Mon, 8 Jan 2024 22:30:28 -0800 Subject: [PATCH 3/3] Only build a preview site when the site actually changes. --- .github/workflows/firebase-hosting-pull-request.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 81f5939..ef32cde 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -2,7 +2,11 @@ # https://github.com/firebase/firebase-tools name: Deploy to Firebase Hosting on PR -'on': pull_request +'on': + pull_request: + paths: + - 'web/**' + - 'eval/eval.go' jobs: build_and_preview: if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'