Skip to content

Commit 7ecee18

Browse files
committed
test combined action
1 parent 1715b14 commit 7ecee18

3 files changed

Lines changed: 79 additions & 106 deletions

File tree

.github/workflows/azure-deploy-www.yml

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
1-
name: deploy www to aca
2-
1+
name: azure deploy www prod
2+
run-name: Deploy to www to ${{ inputs.environment }} by @${{ github.actor }}
33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
paths:
9-
- 'apps/www/**'
10-
- 'internal/components/**'
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
description: 'Deployment environment (production, preview)'
10+
pr_number:
11+
required: false
12+
type: string
13+
description: 'PR number for preview deployments'
14+
update_comment:
15+
required: false
16+
type: boolean
17+
default: false
18+
description: 'Whether to update PR comment with deployment URL'
19+
secrets:
20+
AZURE_CLIENT_ID:
21+
required: true
22+
AZURE_TENANT_ID:
23+
required: true
24+
AZURE_SUBSCRIPTION_ID:
25+
required: true
1126

1227
permissions:
1328
id-token: write # needed for OIDC
1429
contents: read
1530

31+
concurrency:
32+
group: azure-www-prod-deploy
33+
cancel-in-progress: true
34+
35+
env:
36+
RESOURCE_GROUP: ${{ inputs.environment == 'production' && 'rg-designsystemet-prod' || 'rg-designsystemet-test' }}
37+
CONTAINERAPPS_ENV: ${{ inputs.environment == 'production' && 'www-prod-ca' || 'www-test-ca' }}
38+
ACR_NAME: designsystemetacr
39+
APP_NAME: ${{ inputs.environment == 'production' && 'www-prod' || 'www-test-pr-${{ inputs.pr_number }}' }}
40+
IMAGE: ${{ github.event.number }}-${{ github.sha }}
41+
PORT: 8000
42+
1643
jobs:
1744
deploy:
1845
runs-on: ubuntu-latest
@@ -43,14 +70,14 @@ jobs:
4370
- name: deploy
4471
uses: azure/container-apps-deploy-action@29ee19866ec987ededd70b8412d9ee241a9102d1 # v1
4572
with:
46-
resourceGroup: rg-designsystemet-prod
47-
containerAppName: www-prod-env
48-
containerAppEnvironment: www-prod-app
49-
acrName: designsystemetacr
50-
imageToDeploy: designsystemetacr.azurecr.io/www:latest
51-
targetPort: 8000
73+
resourceGroup: ${RESOURCE_GROUP}
74+
containerAppName: ${APP_NAME}
75+
containerAppEnvironment: ${CONTAINERAPPS_ENV}
76+
acrName: ${ACR_NAME}
77+
imageToDeploy: ${IMAGE}
78+
targetPort: ${PORT}
5279
ingress: external
5380
environmentVariables: |
54-
PORT=8000
81+
PORT=${PORT}
5582
HOST=0.0.0.0
56-
ENV=production
83+
ENV=${{ inputs.environment }}

.github/workflows/azure-preview-www.yml

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,99 +3,19 @@ name: azure preview www
33
on:
44
workflow_dispatch:
55
pull_request:
6-
types: [opened, synchronize, reopened]
6+
types: [opened, synchronize]
77
paths:
88
- 'apps/www/**'
99
- 'internal/components/**'
1010

11-
permissions:
12-
id-token: write
13-
contents: read
14-
pull-requests: write
15-
16-
env:
17-
RESOURCE_GROUP: rg-designsystemet-test
18-
CONTAINERAPPS_ENV: www-test-ca
19-
ACR_NAME: designsystemetacr
20-
APP_NAME: www-pr-${{ github.event.number }}
21-
IMAGE: ${{ github.event.number }}-${{ github.sha }}
22-
PORT: 8000
23-
24-
concurrency:
25-
group: azure-www-preview-${{ github.event.pull_request.number || github.run_id }}
26-
cancel-in-progress: true
27-
2811
jobs:
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 (www)
49-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
50-
with:
51-
context: .
52-
file: ./Dockerfile
53-
target: www
54-
platforms: linux/amd64
55-
push: true
56-
tags: ${{ env.ACR_NAME }}.azurecr.io/www:${{ 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/www:${{ 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
12+
deploy-preview:
13+
uses: ./.github/workflows/azure-deploy-www.yml
9814
with:
15+
environment: preview
9916
pr_number: ${{ github.event.number }}
100-
deployment_type: www
101-
deployment_url: https://${{ needs.deploy.outputs.fqdn }}
17+
update_comment: true
18+
secrets:
19+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
20+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
21+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Deploy www to production
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
environment:
6+
type: choice
7+
default: next
8+
description: Deploy to environment
9+
options:
10+
- production
11+
- next
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- 'apps/www/**'
17+
18+
jobs:
19+
deploy-production:
20+
uses: ./.github/workflows/vercel-deploy-www.yml
21+
with:
22+
environment: ${{ github.event.inputs.environment == 'production' && 'production' || 'preview' }}
23+
secrets:
24+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
25+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
26+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

0 commit comments

Comments
 (0)