Skip to content

Commit 73c01d3

Browse files
committed
ci: run website azure deploy only from master
1 parent c12d782 commit 73c01d3

File tree

3 files changed

+76
-62
lines changed

3 files changed

+76
-62
lines changed

.github/workflows/bundle-size.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,35 @@ jobs:
7979
monosize-report.md
8080
pr.txt
8181
82+
# ===================================
83+
# NON PR (MASTER) WORKFLOW STEPS
84+
# ===================================
85+
8286
- name: Build all packages & create reports (non-PR)
8387
if: github.event_name != 'pull_request'
8488
run: yarn nx run-many -t bundle-size --nxBail
8589

90+
- name: Login via Azure CLI (non-PR)
91+
if: github.event_name != 'pull_request'
92+
uses: azure/login@v2
93+
with:
94+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
95+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
96+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
97+
8698
- name: Upload a report (non-PR)
8799
if: github.event_name != 'pull_request'
88100
uses: azure/cli@v2
89101
with:
90102
azcliversion: latest
91-
# TODO: how to set subcription? monosize has no flag for it and gha az cli doesn't support this parameter
103+
# TODO: how to set subcription? monosize has no flag for it and gha az cli doesn't support this parameter
92104
# azureSubscription: 'Bundlesize Testing'
93105
inlineScript: |
94106
yarn monosize upload-report --branch=${{ github.ref }} --commit-sha ${{ github.sha }}
95107
env:
108+
AZCOPY_AUTO_LOGIN_TYPE: 'AZCLI'
109+
SYSTEM_ACCESSTOKEN: ${{ secrets.GITHUB_TOKEN }}
96110
# AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
97111
# AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
98112
# AZURE_SERVICE_CONNECTION_ID: ${{ secrets.AZURE_SERVICE_CONNECTION_ID }}
99113
# BUNDLESIZE_ACCOUNT_NAME: ${{ secrets.BUNDLESIZE_ACCOUNT_NAME }}
100-
SYSTEM_ACCESSTOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-website-deploy-comment.yml

+59-19
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,41 @@ on:
55
types:
66
- completed
77

8+
concurrency:
9+
# see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
10+
group: ${{github.event.workflow_run.id }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
DEPLOY_HOST_URL: https://fluentuipr.z22.web.core.windows.net/
15+
16+
# GitHub Secrets for Azure access
17+
# This service principal ("subscription" is a misleading name) only has access to the fluentuipr storage account
18+
AZURE_SUBSCRIPTION: Azure PR deploy - NEW
19+
AZURE_STORAGE: fluentuipr
20+
821
jobs:
9-
comment:
22+
deploy:
1023
runs-on: ubuntu-latest
1124
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
12-
permissions:
13-
pull-requests: write
25+
outputs:
26+
pr_number: ${{ steps.pr_number.outputs.id }}
27+
website_url: ${{ steps.website_url.outputs.id }}
1428
steps:
15-
- name: Download artifact
29+
- name: Download WebSite artifacts
1630
uses: actions/download-artifact@v4
1731
with:
18-
name: monosize-report
19-
path: ./results
32+
name: pr-website-artifacts
33+
path: ./website
2034
run_id: ${{ github.event.workflow_run.id }}
2135
github-token: ${{ secrets.GITHUB_TOKEN }}
2236

23-
# - name: 'Download artifact'
24-
# uses: dawidd6/action-download-artifact@v2
25-
# with:
26-
# name: pr-website-deploy-url
27-
# path: ./results
28-
# run_id: ${{ github.event.workflow_run.id }}
29-
# workflow: ${{ github.event.workflow.id }}
30-
# workflow_conclusion: success
37+
- uses: actions/download-artifact@v4
38+
with:
39+
name: pr-number
40+
path: ./results
41+
run_id: ${{ github.event.workflow_run.id }}
42+
github-token: ${{ secrets.GITHUB_TOKEN }}
3143

3244
- name: Load PR number
3345
id: pr_number
@@ -36,21 +48,49 @@ jobs:
3648

3749
- name: Load URL
3850
id: website_url
39-
run: echo "::set-output name=id::$(cat website-deploy-url.txt)"
40-
working-directory: ./results
51+
run: echo "::set-output name=id::${{env.DEPLOY_HOST_URL}}pull/${{steps.pr_number.outputs.id}}"
52+
53+
- name: Login via Azure CLI
54+
uses: azure/login@v2
55+
with:
56+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
57+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
58+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
4159

60+
- name: Upload PR WebSite
61+
uses: azure/cli@v2
62+
env:
63+
AZCOPY_AUTO_LOGIN_TYPE: 'AZCLI'
64+
with:
65+
azcliversion: latest
66+
inlineScript: |
67+
az storage blob upload-batch \
68+
--destination '$web' \
69+
--source ./website \
70+
--account-name ${{ env.AZURE_STORAGE }} \
71+
--destination-path pull/${{steps.pr_number.outputs.id}} \
72+
--auth-mode login \
73+
--overwrite
74+
75+
comment:
76+
runs-on: ubuntu-latest
77+
needs: deploy
78+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
79+
permissions:
80+
pull-requests: write
81+
steps:
4282
- name: 'Comment on PR'
4383
uses: marocchino/sticky-pull-request-comment@v2
4484
with:
45-
number: ${{ steps.pr_number.outputs.id }}
85+
number: ${{ needs.deploy.outputs.pr_number }}
4686
message: |
47-
Pull request demo site: [URL](${{steps.pr_number.outputs.id}})
87+
Pull request demo site: [URL](${{needs.deploy.outputs.website_url}})
4888
4989
- name: Update PR deploy site GitHub status
5090
if: github.event_name == 'pull_request'
5191
uses: actions/github-script@v7
5292
with:
5393
script: |
5494
const run = require('./.github/deploy-pr-site-status');
55-
const config = { websiteUrl: '${{steps.website_url.outputs.id}}', prId: '${{steps.pr_number.outputs.id}}'};
95+
const config = { websiteUrl: '${{ needs.deploy.outputs.website_url }}', prId: '${{ needs.deploy.outputs.pr_number }}'};
5696
await run({github,context,core,config});

.github/workflows/pr-website-deploy.yml

+2-41
Original file line numberDiff line numberDiff line change
@@ -63,57 +63,18 @@ jobs:
6363

6464
- name: Generate PR Deploy Site
6565
run: yarn nx run pr-deploy-site:generate:site
66-
67-
- name: Upload WebSite artifacts
68-
uses: actions/upload-artifact@v4
66+
- uses: actions/upload-artifact@v4
6967
with:
7068
name: pr-website-artifacts
7169
if-no-files-found: error
7270
path: |
7371
apps/pr-deploy-site/dist/
7472
75-
deploy:
76-
runs-on: ubuntu-latest
77-
needs: ['bundle']
78-
steps:
79-
- name: Download WebSite artifacts
80-
uses: actions/download-artifact@v4
81-
with:
82-
name: pr-website-artifacts
83-
path: ./pr-deploy-site/
84-
85-
- name: 'Login via Azure CLI'
86-
uses: azure/login@v2
87-
with:
88-
client-id: ${{ secrets.AZURE_CLIENT_ID }}
89-
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
90-
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
91-
92-
- name: Upload PR WebSite
93-
uses: azure/cli@v2
94-
env:
95-
AZCOPY_AUTO_LOGIN_TYPE: 'AZCLI'
96-
with:
97-
azcliversion: latest
98-
inlineScript: |
99-
az storage blob upload-batch \
100-
--destination '$web' \
101-
--source ./pr-deploy-site \
102-
--account-name ${{ env.AZURE_STORAGE }} \
103-
--destination-path ${{ env.DEPLOY_BASE_PATH }} \
104-
--auth-mode login \
105-
--overwrite
106-
107-
- name: Save WebSite DEPLOY url
108-
run: echo https://${{ env.DEPLOY_HOST }}/${{ env.DEPLOY_BASE_PATH }} > website-deploy-url.txt
109-
11073
- name: Save PR number
11174
run: echo ${{ github.event.number }} > pr.txt
112-
11375
- uses: actions/upload-artifact@v4
11476
with:
115-
name: pr-website-deploy-url
77+
name: pr-number
11678
if-no-files-found: error
11779
path: |
118-
website-deploy-url.txt
11980
pr.txt

0 commit comments

Comments
 (0)