diff --git a/k8s-ng/apps/openartifact/apply-sso.py b/k8s-ng/apps/openartifact/apply-sso.py index 099603b..a236981 100644 --- a/k8s-ng/apps/openartifact/apply-sso.py +++ b/k8s-ng/apps/openartifact/apply-sso.py @@ -31,5 +31,12 @@ try: if provider["name"] != "keycloak" or provider["result"] != "applied": raise RuntimeError("OpenArtifact did not apply the Keycloak provider") print("Keycloak SSO provider applied") + publisher = json.loads(post("admin/declarative/apply", { + "manifest": Path("/config/winget-publisher.yaml").read_text(), + })) + items = publisher["items"] + if len(items) != 3 or any(item["result"] != "applied" for item in items): + raise RuntimeError("OpenArtifact did not apply the WinGet publisher policy") + print("WinGet publisher policy applied") finally: post("auth/logout", {}) diff --git a/k8s-ng/apps/openartifact/kustomization.yaml b/k8s-ng/apps/openartifact/kustomization.yaml index 2f981b5..dfd151d 100644 --- a/k8s-ng/apps/openartifact/kustomization.yaml +++ b/k8s-ng/apps/openartifact/kustomization.yaml @@ -13,6 +13,7 @@ configMapGenerator: files: - sso.yaml - apply-sso.py + - winget-publisher.yaml helmCharts: - name: openartifact diff --git a/k8s-ng/apps/openartifact/winget-publisher.yaml b/k8s-ng/apps/openartifact/winget-publisher.yaml new file mode 100644 index 0000000..e545981 --- /dev/null +++ b/k8s-ng/apps/openartifact/winget-publisher.yaml @@ -0,0 +1,39 @@ +apiVersion: openartifact.io/v1 +kind: ServiceAccount +metadata: + name: github-winget +spec: + description: Publishes the Hexor WinGet catalog from GitHub Actions +--- +apiVersion: openartifact.io/v1 +kind: PermissionTarget +metadata: + name: github-winget-publish +spec: + repository_filter: '^hexor-winget$' + path_pattern: '.*' + actions: [read, write] + assignments: + users: [github-winget] +--- +apiVersion: openartifact.io/v1 +kind: OIDCTrustPolicy +metadata: + name: github-winget-publish +spec: + issuer: https://token.actions.githubusercontent.com + audience: https://repo.hexor.cy + service_account: github-winget + token_ttl_seconds: 900 + enabled: true + conditions: + - claim: repository_owner_id + patterns: ['4666566'] + - claim: repository_id + patterns: ['678451959'] + - claim: event_name + patterns: [repository_dispatch, workflow_dispatch] + - claim: ref + patterns: ['refs/heads/main'] + - claim: workflow_ref + patterns: ['house-of-vanity/arch_repo/.github/workflows/publish-winget.yml@refs/heads/main']