Skip to content

Commit 13e7a61

Browse files
committed
build: Integrate 1Password provider for GitHub token management
- Added pulumi-onepassword dependency to manage GitHub tokens securely. - Updated Pulumi configuration to include 1Password account details. - Modified testpipeline.py to fetch GitHub token from 1Password and configure GitHub provider accordingly.
1 parent df4352c commit 13e7a61

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
config:
22
github:owner: nf-core-tf
3-
# https://start.1password.com/open/i?a=O5GICFDKPNABLLVGMKBL5JWDWA&v=rdfcz6oy6qxxrc4clu467a7dmm&i=4ajrv44kc5lcbboa37fr5oydla&h=nf-core.1password.eu
3+
# GitHub token stored in 1Password: https://start.1password.com/open/i?a=O5GICFDKPNABLLVGMKBL5JWDWA&v=rdfcz6oy6qxxrc4clu467a7dmm&i=4ajrv44kc5lcbboa37fr5oydla&h=nf-core.1password.eu
4+
# 1Password provider configuration
5+
pulumi-onepassword:account: nf-core.1password.eu
46
environment:
57
- github-nf-core-tf
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
config:
22
github:owner: nf-core
3-
# https://start.1password.com/open/i?a=O5GICFDKPNABLLVGMKBL5JWDWA&v=rdfcz6oy6qxxrc4clu467a7dmm&i=ttqz63qvlr5qfwfde424nbl4re&h=nf-core.1password.eu
4-
environment:
5-
- github-prod
3+
pulumi-onepassword:service_account_token:
4+
secure: AAABAOVuHjkvr7WBtuxqrIv2W0MkvP9DkIoAqXc2YKGgbjDWCQWGKrXV0wZbmA+064gFec1V6fPVSphDWm9CPx1yq1WkVSnfX4gpNvQKDtJUFq8dqf5Z0XrNljAEr3Tegp3J6L08wj0zvN8R/HfveoOysKzmn6iUuwCEoizq4Yeaz8z20lWpWorE0ICHo6AXBTTH/qGC1HSW9qFfnGtUPvmnNHt2mLhFjnrOGP6My9m3x3tF9no+ptFdWN54lhCyARcBhn6JP2MhEJ09UPXw+uxwFfj8euwgU/pRsqdu22pJLMLA5mOn5gShYcRFT4eaWoRiu9eYaElItfgB8HSKiWrk26+eDz1VvdjdqfcUeLp7X2BGxD50q3s5Y6IRvHKhYZhJzNGq57qhk4M8sYXcl3sDDLZcKuidv4/NfFlLcop5i4KJ8lVBz1jP0v6QQHWjGXT6U1CvX5EwhqemEO862V/5RRYfy/qX85aVv/Xf01lIosGF2v5C5888F0mh8kelKwZGoqm6K+5o1Cy8V/nfCdmRXCEo7DY0iBYa0LfLmv++587rMs0kS84ocBIm/CjdgLoG+zlJRZGXcA0BlJwcWGYPaJ5J/FNDagMNikjwnHmHcTU0nflbzaArC4GJKMboKhl0OFxU3Z8KmhPIv0tUQBEwceDCi3fbEFdgvgnP0kjbFOgT5LMht44M+0B/r7KWZWwYDmZI5t7Bh5FC+qWg+GUiK5MtpOOy9MNi0gC7WrvTH3vhXpGzfx41EOdu3LF6SycigF0IMznl784PimFX1fMxH+9pX29dUP5LxXkS2INs6QQQOcOmlRKZqEsgZOPA34fzyNQliIj1thmS6GrC80UZcAPQ9HZtvKHX2/EZnzjTKcNvQrwsbRlD2de05xRjKCstAwQJVusN0+t8zMzeqgYUe1+Y9+fQ+5nZ3+uQvj9OvLjHFGuzYUwYAbSnAWgWZgUQ4gXNac7MCR4uc5ENJOByE72yL0SuJrGbhPACOE0rZTx35L88+XD7wGbM0iJ8D/2QU5XOgvXaXHQZk4xxsmDg9hY7klQ1atf05eRD+nO9htMgbuvlWeA478vZo2+BbOjn5ziHlDvs9+/NNi3VmP+10WtEkecL71luvmnMyoxI2oouQfcT9xEWW7Xj830BddVO3lr+C5Sdkp27ZENGEhZruZtpzH4x

pulumi/github/repos/pipelines/testpipeline.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
# https://github.com/pulumi/examples/blob/74db62a03d013c2854d2cf933c074ea0a3bbf69d/testing-unit-py/test_ec2.py
44
import pulumi
55
import pulumi_github as github
6+
import pulumi_onepassword as onepassword
7+
8+
# Configure 1Password provider with account details
9+
onepassword_provider = onepassword.Provider(
10+
"onepassword-provider",
11+
account="nf-core.1password.eu"
12+
)
13+
14+
# Fetch GitHub token from 1Password
15+
# Item ID from the 1Password URL: 4ajrv44kc5lcbboa37fr5oydla
16+
# Vault ID from the 1Password URL: rdfcz6oy6qxxrc4clu467a7dmm
17+
github_token_item = onepassword.get_item(
18+
vault="rdfcz6oy6qxxrc4clu467a7dmm", # Vault ID from the 1Password URL
19+
uuid="4ajrv44kc5lcbboa37fr5oydla", # Item ID from the 1Password URL
20+
opts=pulumi.InvokeOptions(provider=onepassword_provider)
21+
)
22+
23+
# Configure GitHub provider with token from 1Password
24+
github_provider = github.Provider(
25+
"github-provider",
26+
token=github_token_item.password, # The token is stored in the password field
27+
owner="nf-core-tf"
28+
)
629

730
NAME = "testpipeline"
831

@@ -58,6 +81,7 @@
5881
visibility="public",
5982
topics=TOPICS, # 'repo_keywords' => 'Minimum keywords set',
6083
# NOTE: @mirpedrol asked if we could add missing topics without deleting existing ones
84+
opts=pulumi.ResourceOptions(provider=github_provider)
6185
)
6286

6387

@@ -69,21 +93,21 @@
6993
f"branch_default_{NAME}",
7094
branch="main",
7195
repository=NAME,
72-
opts=pulumi.ResourceOptions(protect=True),
96+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
7397
)
7498
# 'branch_dev_exists' => 'dev branch: branch must exist',
7599
branch_dev_testpipeline = github.Branch(
76100
f"branch_dev_{NAME}",
77101
branch="dev",
78102
repository=NAME,
79-
opts=pulumi.ResourceOptions(protect=True),
103+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
80104
)
81105
# 'branch_template_exists' => 'TEMPLATE branch: branch must exist',
82106
branch_template_testpipeline = github.Branch(
83107
f"branch_template_{NAME}",
84108
branch="TEMPLATE",
85109
repository=NAME,
86-
opts=pulumi.ResourceOptions(protect=True),
110+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
87111
)
88112
# Add branch protections https://github.com/nf-core/website/blob/33acd6a2fab2bf9251e14212ce731ef3232b5969/public_html/pipeline_health.php#L296
89113
# NOTE This uses the new Rulesets instead of classic branch protection rule
@@ -122,7 +146,7 @@
122146
),
123147
),
124148
target="branch",
125-
opts=pulumi.ResourceOptions(protect=True),
149+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
126150
)
127151
# TODO 'branch_dev_strict_updates' => 'dev branch: do not require branch to be up to date before merging',
128152
ruleset_branch_dev_testpipeline = github.RepositoryRuleset(
@@ -166,7 +190,7 @@
166190
),
167191
),
168192
target="branch",
169-
opts=pulumi.ResourceOptions(protect=True),
193+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
170194
)
171195
# TODO Double check
172196
# Template branch protection https://github.com/nf-core/website/blob/33acd6a2fab2bf9251e14212ce731ef3232b5969/public_html/pipeline_health.php#L509
@@ -196,19 +220,21 @@
196220
update=True,
197221
),
198222
target="branch",
199-
opts=pulumi.ResourceOptions(protect=True),
223+
opts=pulumi.ResourceOptions(protect=True, provider=github_provider),
200224
)
201225
# 'team_contributors' => 'Write access for nf-core/contributors',
202226
contributors_team_repo_testpipeline = github.TeamRepository(
203227
f"contributors_team_repo_{NAME}",
204228
team_id="contributors",
205229
repository=NAME,
206230
permission="push",
231+
opts=pulumi.ResourceOptions(provider=github_provider),
207232
)
208233
# 'team_core' => 'Admin access for nf-core/core',
209234
core_team_repo_testpipeline = github.TeamRepository(
210235
f"core_team_repo_{NAME}",
211236
team_id="core",
212237
repository=NAME,
213238
permission="admin",
239+
opts=pulumi.ResourceOptions(provider=github_provider),
214240
)

pulumi/github/repos/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ requires-python = ">=3.12"
77
dependencies = [
88
"pulumi>=3",
99
"pulumi-github>=6.7.2",
10+
"pulumi-onepassword>=1.1.3",
1011
]

pulumi/github/repos/uv.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)