|
3 | 3 | # https://github.com/pulumi/examples/blob/74db62a03d013c2854d2cf933c074ea0a3bbf69d/testing-unit-py/test_ec2.py |
4 | 4 | import pulumi |
5 | 5 | 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 | +) |
6 | 29 |
|
7 | 30 | NAME = "testpipeline" |
8 | 31 |
|
|
58 | 81 | visibility="public", |
59 | 82 | topics=TOPICS, # 'repo_keywords' => 'Minimum keywords set', |
60 | 83 | # NOTE: @mirpedrol asked if we could add missing topics without deleting existing ones |
| 84 | + opts=pulumi.ResourceOptions(provider=github_provider) |
61 | 85 | ) |
62 | 86 |
|
63 | 87 |
|
|
69 | 93 | f"branch_default_{NAME}", |
70 | 94 | branch="main", |
71 | 95 | repository=NAME, |
72 | | - opts=pulumi.ResourceOptions(protect=True), |
| 96 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
73 | 97 | ) |
74 | 98 | # 'branch_dev_exists' => 'dev branch: branch must exist', |
75 | 99 | branch_dev_testpipeline = github.Branch( |
76 | 100 | f"branch_dev_{NAME}", |
77 | 101 | branch="dev", |
78 | 102 | repository=NAME, |
79 | | - opts=pulumi.ResourceOptions(protect=True), |
| 103 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
80 | 104 | ) |
81 | 105 | # 'branch_template_exists' => 'TEMPLATE branch: branch must exist', |
82 | 106 | branch_template_testpipeline = github.Branch( |
83 | 107 | f"branch_template_{NAME}", |
84 | 108 | branch="TEMPLATE", |
85 | 109 | repository=NAME, |
86 | | - opts=pulumi.ResourceOptions(protect=True), |
| 110 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
87 | 111 | ) |
88 | 112 | # Add branch protections https://github.com/nf-core/website/blob/33acd6a2fab2bf9251e14212ce731ef3232b5969/public_html/pipeline_health.php#L296 |
89 | 113 | # NOTE This uses the new Rulesets instead of classic branch protection rule |
|
122 | 146 | ), |
123 | 147 | ), |
124 | 148 | target="branch", |
125 | | - opts=pulumi.ResourceOptions(protect=True), |
| 149 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
126 | 150 | ) |
127 | 151 | # TODO 'branch_dev_strict_updates' => 'dev branch: do not require branch to be up to date before merging', |
128 | 152 | ruleset_branch_dev_testpipeline = github.RepositoryRuleset( |
|
166 | 190 | ), |
167 | 191 | ), |
168 | 192 | target="branch", |
169 | | - opts=pulumi.ResourceOptions(protect=True), |
| 193 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
170 | 194 | ) |
171 | 195 | # TODO Double check |
172 | 196 | # Template branch protection https://github.com/nf-core/website/blob/33acd6a2fab2bf9251e14212ce731ef3232b5969/public_html/pipeline_health.php#L509 |
|
196 | 220 | update=True, |
197 | 221 | ), |
198 | 222 | target="branch", |
199 | | - opts=pulumi.ResourceOptions(protect=True), |
| 223 | + opts=pulumi.ResourceOptions(protect=True, provider=github_provider), |
200 | 224 | ) |
201 | 225 | # 'team_contributors' => 'Write access for nf-core/contributors', |
202 | 226 | contributors_team_repo_testpipeline = github.TeamRepository( |
203 | 227 | f"contributors_team_repo_{NAME}", |
204 | 228 | team_id="contributors", |
205 | 229 | repository=NAME, |
206 | 230 | permission="push", |
| 231 | + opts=pulumi.ResourceOptions(provider=github_provider), |
207 | 232 | ) |
208 | 233 | # 'team_core' => 'Admin access for nf-core/core', |
209 | 234 | core_team_repo_testpipeline = github.TeamRepository( |
210 | 235 | f"core_team_repo_{NAME}", |
211 | 236 | team_id="core", |
212 | 237 | repository=NAME, |
213 | 238 | permission="admin", |
| 239 | + opts=pulumi.ResourceOptions(provider=github_provider), |
214 | 240 | ) |
0 commit comments