@@ -3,99 +3,22 @@ name: azure preview storybook
33on :
44 workflow_dispatch :
55 pull_request :
6- types : [opened, synchronize, reopened ]
6+ types : [opened, synchronize]
77 paths :
88 - ' apps/storybook/**'
99 - ' internal/components/**'
1010
1111permissions :
12- id-token : write
1312 contents : read
14- pull-requests : write
15-
16- env :
17- RESOURCE_GROUP : rg-designsystemet-test
18- CONTAINERAPPS_ENV : storybook-test-ca
19- ACR_NAME : designsystemetacr
20- APP_NAME : storybook-pr-${{ github.event.number }}
21- IMAGE : ${{ github.event.number }}-${{ github.sha }}
22- PORT : 6006
23-
24- concurrency :
25- group : azure-storybook-preview-${{ github.event.pull_request.number || github.run_id }}
26- cancel-in-progress : true
2713
2814jobs :
29- deploy :
30- if : ${{ github.repository == 'digdir/designsystemet' }}
31- runs-on : ubuntu-latest
32- outputs :
33- fqdn : ${{ steps.fqdn.outputs.fqdn }}
34-
35- steps :
36- - uses : actions/checkout@v4
37-
38- - name : az login (oidc)
39- uses : azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
40- with :
41- client-id : ${{ secrets.AZURE_CLIENT_ID }}
42- tenant-id : ${{ secrets.AZURE_TENANT_ID }}
43- subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
44-
45- - name : acr login (for docker push)
46- run : az acr login --name ${{ env.ACR_NAME }}
47-
48- - name : build & push image (storybook)
49- uses : docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
50- with :
51- context : .
52- file : ./Dockerfile
53- target : storybook
54- platforms : linux/amd64
55- push : true
56- tags : ${{ env.ACR_NAME }}.azurecr.io/storybook:${{ env.IMAGE }}
57-
58- - name : get acr creds (masked)
59- id : acr
60- shell : bash
61- run : |
62- set -euo pipefail
63- az acr update -n "${ACR_NAME}" --admin-enabled true >/dev/null
64- USER=$(az acr credential show -n "${ACR_NAME}" --query username -o tsv)
65- PASS=$(az acr credential show -n "${ACR_NAME}" --query 'passwords[0].value' -o tsv)
66- echo "::add-mask::${USER}"
67- echo "::add-mask::${PASS}"
68- echo "user=${USER}" >> "$GITHUB_OUTPUT"
69- echo "pass=${PASS}" >> "$GITHUB_OUTPUT"
70-
71- - name : deploy (no mi; use registry creds)
72- uses : azure/container-apps-deploy-action@29ee19866ec987ededd70b8412d9ee241a9102d1 # v1
73- with :
74- resourceGroup : ${{ env.RESOURCE_GROUP }}
75- containerAppEnvironment : ${{ env.CONTAINERAPPS_ENV }}
76- containerAppName : ${{ env.APP_NAME }}
77- imageToDeploy : ${{ env.ACR_NAME }}.azurecr.io/storybook:${{ env.IMAGE }}
78- registryUrl : ${{ env.ACR_NAME }}.azurecr.io
79- registryUsername : ${{ steps.acr.outputs.user }}
80- registryPassword : ${{ steps.acr.outputs.pass }}
81- targetPort : ${{ env.PORT }}
82- ingress : external
83- environmentVariables : |
84- PORT=${{ env.PORT }}
85- HOST=0.0.0.0
86-
87- - name : fetch fqdn
88- id : fqdn
89- run : |
90- FQDN=$(az containerapp show -n "${APP_NAME}" -g "${RESOURCE_GROUP}" --query properties.configuration.ingress.fqdn -o tsv)
91- echo "fqdn=${FQDN}" >> "$GITHUB_OUTPUT"
92- echo "Resolved FQDN: ${FQDN}" # log for visibility
93-
94- update-comment :
95- if : ${{ github.event_name == 'pull_request' }}
96- needs : deploy
97- uses : ./.github/workflows/preview-comment.yml
15+ deploy-preview :
16+ uses : ./.github/workflows/azure-deploy-storybook.yml
9817 with :
18+ environment : preview
9919 pr_number : ${{ github.event.number }}
100- deployment_type : storybook
101- deployment_url : https://${{ needs.deploy.outputs.fqdn }}
20+ update_comment : true
21+ secrets :
22+ AZURE_CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
23+ AZURE_TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
24+ AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
0 commit comments