Skip to content

Commit 6ca3488

Browse files
author
root
committed
ci(deploy): record GitHub Deployment and status for PR preview channels
1 parent f1c13cc commit 6ca3488

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/deployment-pr.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,40 @@ jobs:
2626
with:
2727
node-version: 20
2828
- uses: FirebaseExtended/action-hosting-deploy@v0
29+
id: firebase_deploy
2930
with:
3031
repoToken: "${{ secrets.GITHUB_TOKEN }}"
3132
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHATSANALYZE_80665 }}"
3233
projectId: whatsanalyze-80665
3334
env:
3435
FIREBASE_CLI_PREVIEWS: hostingchannels
36+
- name: Create GitHub Deployment
37+
if: steps.firebase_deploy.outputs.details_url != ''
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
const url = '${{ steps.firebase_deploy.outputs.details_url }}';
42+
const deployment = await github.rest.repos.createDeployment({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
ref: context.payload.pull_request ? context.payload.pull_request.head.sha : context.sha,
46+
environment: 'Preview',
47+
description: 'Firebase Hosting Preview Deployment',
48+
auto_merge: false,
49+
required_contexts: [],
50+
transient_environment: true
51+
});
52+
if (deployment.data && deployment.data.id) {
53+
await github.rest.repos.createDeploymentStatus({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
deployment_id: deployment.data.id,
57+
state: 'success',
58+
environment: 'Preview',
59+
environment_url: url,
60+
description: 'Deployed to Firebase Hosting preview channel'
61+
});
62+
}
3563
- name: Sentry Release
3664
uses: getsentry/action-release@v1.1.5
3765
env:

0 commit comments

Comments
 (0)