Skip to content

Commit 57e9987

Browse files
authored
ci: Enable deploy via action, fix model uuid passing (#399)
Sample run: https://github.com/canonical/identity-platform-login-ui-operator/actions/runs/21365488129
2 parents d5886ba + 0c7554d commit 57e9987

3 files changed

Lines changed: 54 additions & 11 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
model:
7+
description: Target Juju model
8+
required: true
9+
type: choice
10+
options:
11+
- blue-iam # dev
12+
- green-iam # stg
13+
revision:
14+
description: Charm revision to deploy
15+
required: true
16+
type: string
17+
dry-run:
18+
description: Run Terraform in plan mode (dry-run) instead of apply
19+
required: true
20+
type: boolean
21+
default: true
22+
channel:
23+
description: Charm channel to deploy from
24+
required: false
25+
type: string
26+
default: latest/edge
27+
28+
jobs:
29+
deploy:
30+
name: Deploy Charm to ${{ inputs.model }}
31+
uses: canonical/identity-team/.github/workflows/charm-deploy.yaml@6b27807be4ec7c25045d52ef09ac780d684f65a2 # v1.10.0
32+
with:
33+
model: ${{ inputs.model }}
34+
revision: ${{ inputs.revision }}
35+
channel: ${{ inputs.channel }}
36+
application: login-ui
37+
tf-application-resource: module.application.juju_application.application
38+
plan-only: ${{ inputs.dry-run }}
39+
secrets:
40+
CLIENT_ID: ${{ inputs.model == 'blue-iam' && secrets.JIMM_DEV_CLIENT_ID || secrets.JIMM_STG_CLIENT_ID }}
41+
CLIENT_SECRET: ${{ inputs.model == 'blue-iam' && secrets.JIMM_DEV_CLIENT_SECRET || secrets.JIMM_STG_CLIENT_SECRET }}
42+
JIMM_URL: ${{ secrets.JIMM_URL }}
43+
MODEL_UUID: ${{ inputs.model == 'blue-iam' && secrets.DEV_MODEL_UUID || secrets.STG_MODEL_UUID }}

.github/workflows/publish.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
tags:
77
- "v**"
8-
- "track**"
8+
- "track**"
99

1010
workflow_dispatch:
1111
inputs:
@@ -21,7 +21,7 @@ on:
2121
type: string
2222
override-ci:
2323
description: Override standard release flow
24-
required: true
24+
required: true
2525
type: boolean
2626

2727
jobs:
@@ -39,7 +39,7 @@ jobs:
3939
concurrency:
4040
group: ${{ needs.publish.outputs.track }}-${{ needs.publish.outputs.channel }}
4141
cancel-in-progress: true
42-
needs:
42+
needs:
4343
- publish
4444
outputs:
4545
revision: ${{ steps.set-revision.outputs.revision }}
@@ -50,7 +50,7 @@ jobs:
5050
with:
5151
fetch-depth: 0
5252
- name: Set charm name
53-
id: set-charm-name
53+
id: set-charm-name
5454
run: echo charm_name=$(cat charmcraft.yaml | yq '.name') >> $GITHUB_OUTPUT
5555
- name: Set revision
5656
id: set-revision
@@ -64,7 +64,7 @@ jobs:
6464
CHARM_NAME: ${{ steps.set-charm-name.outputs.charm_name }}
6565
# only cater for latest track for now
6666
TRACK: latest
67-
67+
6868
dev-deploy:
6969
concurrency:
7070
group: ${{ needs.publish.outputs.track }}-${{ needs.publish.outputs.channel }}
@@ -75,7 +75,7 @@ jobs:
7575
if: ${{ (needs.publish.outputs.channel == 'latest/edge') }}
7676
uses: canonical/identity-team/.github/workflows/charm-deploy.yaml@6b27807be4ec7c25045d52ef09ac780d684f65a2 # v1.10.0
7777
with:
78-
model: dev-iam
78+
model: blue-iam
7979
revision: ${{ needs.revision.outputs.revision }}
8080
channel: ${{ needs.publish.outputs.channel}}
8181
application: login-ui
@@ -85,7 +85,7 @@ jobs:
8585
CLIENT_SECRET: ${{ secrets.JIMM_DEV_CLIENT_SECRET }}
8686
JIMM_URL: ${{ secrets.JIMM_URL }}
8787
MODEL_UUID: ${{ secrets.DEV_MODEL_UUID }}
88-
88+
8989
stg-deploy:
9090
concurrency:
9191
group: ${{ needs.publish.outputs.track }}-${{ needs.publish.outputs.channel }}
@@ -96,7 +96,7 @@ jobs:
9696
if: ${{ (needs.publish.outputs.channel == 'latest/stable') }}
9797
uses: canonical/identity-team/.github/workflows/charm-deploy.yaml@6b27807be4ec7c25045d52ef09ac780d684f65a2 # v1.10.0
9898
with:
99-
model: stg-iam
99+
model: green-iam
100100
revision: ${{ needs.revision.outputs.revision }}
101101
channel: ${{ needs.publish.outputs.channel}}
102102
application: login-ui
@@ -106,4 +106,3 @@ jobs:
106106
CLIENT_SECRET: ${{ secrets.JIMM_STG_CLIENT_SECRET }}
107107
JIMM_URL: ${{ secrets.JIMM_URL }}
108108
MODEL_UUID: ${{ secrets.STG_MODEL_UUID }}
109-

deployment/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ provider "juju" {
5858
}
5959

6060
data "juju_model" "model" {
61-
uuid = var.model
61+
name = var.model
62+
owner = format("%s@serviceaccount", var.client_id)
6263
}
6364

6465
module "application" {
@@ -70,4 +71,4 @@ module "application" {
7071
config = var.charm.config
7172
channel = var.channel
7273
revision = var.revision
73-
}
74+
}

0 commit comments

Comments
 (0)