Skip to content

Commit

Permalink
build(preview): use angular/dev-infra for preview deployment (#991)
Browse files Browse the repository at this point in the history
Using the same actions as the original adev.
  • Loading branch information
lacolaco authored Nov 20, 2024
1 parent 58f44e9 commit abd8414
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 45 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/adev-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ jobs:
common --color=yes
- run: yarn install
- run: yarn build
- run: chmod 755 build/dist/bin/adev/build/browser
- name: Inject pull request number
run: echo "${{ github.event.pull_request.number }}" >> __metadata__pull_number.txt
working-directory: build/dist/bin/adev/build/browser
- uses: actions/upload-artifact@v4
- uses: angular/dev-infra/github-actions/previews/pack-and-upload-artifact@53fb7c37cf14343f14ed79e2fefbbb2489ead4ee
with:
name: adev-preview
path: build/dist/bin/adev/build/browser
workflow-artifact-name: 'adev-preview'
pull-number: '${{ github.event.pull_request.number }}'
artifact-build-revision: '${{github.event.pull_request.head.sha}}'
deploy-directory: './build/dist/bin/adev/build/browser'
45 changes: 7 additions & 38 deletions .github/workflows/adev-preview-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,19 @@ permissions:

env:
BUILD_DIR: build/dist/bin/adev/build/browser
PREVIEW_PROJECT: angular-ja

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- name: Download adev preview artifact from previous workflow run
uses: actions/download-artifact@v4
- uses: angular/dev-infra/github-actions/previews/upload-artifacts-to-firebase@53fb7c37cf14343f14ed79e2fefbbb2489ead4ee
with:
name: adev-preview
path: ${{ env.BUILD_DIR }}
github-token: '${{secrets.GITHUB_TOKEN}}'
run-id: ${{ github.event.workflow_run.id }}
- name: Extract pull request number
id: pr-number
run: |
PR_NUMBER=$(cat ./$BUILD_DIR/__metadata__pull_number.txt)
echo 'value=$PR_NUMBER' >> $GITHUB_OUTPUT
- name: Deploy to Firebase Hosting Preview
id: firebase-deploy
uses: FirebaseExtended/[email protected]
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
projectId: angular-ja
channelId: pr-${{ steps.pr-number.outputs.value }}
expires: 7d
disableComment: true
- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ steps.pr-number.outputs.value }}
comment-author: 'github-actions[bot]'
body-includes: 'Preview deployed'
- name: Comment on pull request
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ steps.pr-number.outputs.value }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
Preview deployed: ${{ steps.firebase-deploy.outputs.details_url }} (commit: ${{ github.event.workflow_run.head_sha }})
workflow-artifact-name: 'adev-preview'
firebase-config-dir: './'
firebase-public-dir: './adev/build/browser'
firebase-project-id: '${{env.PREVIEW_PROJECT}}'
firebase-service-key: '${{secrets.FIREBASE_SERVICE_ACCOUNT}}'

0 comments on commit abd8414

Please sign in to comment.