From 6ae9107c0e50c2472de55f3e8e95a6ba0643e7eb Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Thu, 2 Nov 2023 13:56:09 +0000 Subject: [PATCH] ci: automatically deploy dev-app to firebase for main branch Automatically deploys the dev-app to firebase for pushes to the `main` branch. Note: not using `material2-dev` as it would complicate automated deployement as service key creation is limited given the project being a 1P-managed GCP project. --- .../workflows/deploy-dev-app-main-push.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/deploy-dev-app-main-push.yml diff --git a/.github/workflows/deploy-dev-app-main-push.yml b/.github/workflows/deploy-dev-app-main-push.yml new file mode 100644 index 000000000000..e5f832cbc5b4 --- /dev/null +++ b/.github/workflows/deploy-dev-app-main-push.yml @@ -0,0 +1,46 @@ +name: Deploying dev-app to Firebase [main push]. + +on: + push: + branches: [main] + +permissions: {} + +env: + PREVIEW_PROJECT: ng-dev-previews + PREVIEW_SITE: ng-dev-previews-comp + PREVIEW_CHANNEL: main-branch + +jobs: + deploy-material2-dev: + runs-on: ubuntu-latest + steps: + - name: Initialize environment + uses: angular/dev-infra/github-actions/npm/checkout-and-setup-node@fb30926790c6225d553b91a4818cab2fdde4fb4e + with: + cache-node-modules: true + - name: Setup Bazel + uses: angular/dev-infra/github-actions/bazel/setup@fb30926790c6225d553b91a4818cab2fdde4fb4e + - name: Setup Bazel RBE + uses: angular/dev-infra/github-actions/bazel/configure-remote@fb30926790c6225d553b91a4818cab2fdde4fb4e + + - run: yarn -s deploy-dev-app + + - name: Configure Firebase deploy target + run: | + # We can use `npx` as the Firebase deploy actions uses it too. + npx -y firebase-tools@latest target:clear --project ${{env.PREVIEW_PROJECT}} hosting dev-app + npx -y firebase-tools@latest target:apply --project ${{env.PREVIEW_PROJECT}} hosting dev-app ${{env.PREVIEW_SITE}} + + - uses: FirebaseExtended/action-hosting-deploy@638d3c162747cead0c1c0d3093208ed59dfd8231 # v0 + id: deploy + with: + # Note: No token used here as the action otherwise may attempt to post a comment. + repoToken: '' + firebaseServiceAccount: '${{secrets.FIREBASE_PREVIEW_SERVICE_TOKEN}}' + projectId: '${{env.PREVIEW_PROJECT}}' + channelId: '${{env.PREVIEW_CHANNEL}}' + + - name: Result + run: | + echo "Deployed to: ${{steps.deploy.outputs.details_url}}"