Skip to content

Commit

Permalink
Create task to apply staging config
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal committed Nov 14, 2024
1 parent e4d7b6a commit 31f5922
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
31 changes: 31 additions & 0 deletions taskcluster/kinds/tc-admin/kind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---

loader: taskgraph.loader.transform:loader

transforms:
- taskgraph.transforms.run:transforms
- taskgraph.transforms.task:transforms

task-defaults:
worker-type: t-linux
worker:
docker-image: {in-tree: python3.11}
max-run-time: 3600
run:
cwd: '{checkout}'
using: run-task
checkout: true

tasks:
apply-staging:
description: "Run `tc-admin apply --envrionment=staging` to apply config to Taskcluster stage"
scopes:
- secrets:get:project/releng/fxci-config/taskcluster-stage-client
run:
command: >-
pip install --user -r requirements/base.txt &&
pip install --user --no-deps . &&
python taskcluster/scripts/tc-admin-apply-staging.py
29 changes: 29 additions & 0 deletions taskcluster/scripts/tc-admin-apply-staging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
import subprocess

import taskcluster

assert "TASKCLUSTER_PROXY_URL" in os.environ
options = {"rootUrl": os.environ["TASKCLUSTER_PROXY_URL"]}
secrets = taskcluster.Secrets(options)

result = secrets.get("project/releng/fxci-config/taskcluster-stage-client")
assert result

auth = result["secret"]
assert isinstance(auth, dict)

env = os.environ.copy()
del env["TASKCLUSTER_PROXY_URL"] # ensure we don't use the proxy client
env.update(
{
"TASKCLUSTER_ROOT_URL": "https://stage.taskcluster.nonprod.cloudops.mozgcp.net",
"TASKCLUSTER_CLIENT_ID": auth["clientId"],
"TASKCLUSTER_ACCESS_TOKEN": auth["accessToken"],
}
)
subprocess.run(["tc-admin", "apply", "--environment=staging"], env=env, check=True)

0 comments on commit 31f5922

Please sign in to comment.