Skip to content

Commit 9281528

Browse files
authored
Add S3 authentication (#176)
1 parent 0f64e48 commit 9281528

File tree

12 files changed

+2679
-45
lines changed

12 files changed

+2679
-45
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: |
4848
set -euo pipefail
4949
latest_version="$(jq -r '.version' package.json)"
50-
count_expected=15
50+
count_expected=16
5151
count_actual="$(grep -c "setup-pixi@v$latest_version" README.md || true)"
5252
if [ "$count_actual" -ne "$count_expected" ]; then
5353
echo "::error file=README.md::Expected $count_expected mentions of \`setup-pixi@v$latest_version\` in README.md, but found $count_actual."

.github/workflows/test.yml

+19
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,25 @@ jobs:
438438
run: |
439439
test -f .pixi/envs/default/conda-meta/private-package-0.0.1-0.json
440440
441+
auth-s3-install:
442+
strategy:
443+
matrix:
444+
os: [ubuntu-latest, macos-latest, windows-latest]
445+
runs-on: ${{ matrix.os }}
446+
steps:
447+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
448+
- name: Move pixi.toml
449+
run: mv test/auth-s3/* .
450+
- uses: ./
451+
with:
452+
cache: false
453+
auth-host: s3://rattler-s3-testing
454+
auth-s3-access-key-id: ${{ secrets.PIXI_TEST_R2_ACCESS_KEY_ID }}
455+
auth-s3-secret-access-key: ${{ secrets.PIXI_TEST_R2_SECRET_ACCESS_KEY }}
456+
- name: Ensure private package is installed
457+
run: |
458+
test -f .pixi/envs/default/conda-meta/my-webserver-0.1.0-pyh4616a5c_0.json
459+
441460
pixi-shell:
442461
strategy:
443462
matrix:

README.md

+37-18
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ GitHub Action to set up the [pixi](https://github.com/prefix-dev/pixi) package m
2323
## Usage
2424

2525
```yml
26-
- uses: prefix-dev/setup-pixi@v0.8.2
26+
- uses: prefix-dev/setup-pixi@v0.8.3
2727
with:
28-
pixi-version: v0.41.1
28+
pixi-version: v0.41.4
29+
2930
cache: true
3031
auth-host: prefix.dev
3132
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
@@ -34,7 +35,7 @@ GitHub Action to set up the [pixi](https://github.com/prefix-dev/pixi) package m
3435
3536
> [!WARNING]
3637
> Since pixi is not yet stable, the API of this action may change between minor versions.
37-
> Please pin the versions of this action to a specific version (i.e., `prefix-dev/setup-pixi@v0.8.2`) to avoid breaking changes.
38+
> Please pin the versions of this action to a specific version (i.e., `prefix-dev/setup-pixi@v0.8.3`) to avoid breaking changes.
3839
> You can automatically update the version of this action by using [Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot).
3940
>
4041
> Put the following in your `.github/dependabot.yml` file to enable Dependabot for your GitHub Actions:
@@ -73,7 +74,7 @@ In order to not exceed the [10 GB cache size limit](https://docs.github.com/en/a
7374
This can be done by setting the `cache-write` argument.
7475

7576
```yml
76-
- uses: prefix-dev/setup-pixi@v0.8.2
77+
- uses: prefix-dev/setup-pixi@v0.8.3
7778
with:
7879
cache: true
7980
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
@@ -118,7 +119,7 @@ test:
118119
environment: [py311, py312]
119120
steps:
120121
- uses: actions/checkout@v4
121-
- uses: prefix-dev/setup-pixi@v0.8.2
122+
- uses: prefix-dev/setup-pixi@v0.8.3
122123
with:
123124
environments: ${{ matrix.environment }}
124125
```
@@ -128,7 +129,7 @@ test:
128129
The following example will install both the `py311` and the `py312` environment on the runner.
129130

130131
```yml
131-
- uses: prefix-dev/setup-pixi@v0.8.2
132+
- uses: prefix-dev/setup-pixi@v0.8.3
132133
with:
133134
# separated by spaces
134135
environments: >-
@@ -149,6 +150,7 @@ There are currently three ways to authenticate with pixi:
149150
- using a token
150151
- using a username and password
151152
- using a conda-token
153+
- using an S3 key pair
152154

153155
For more information, see the [pixi documentation](https://prefix.dev/docs/pixi/authentication).
154156

@@ -163,7 +165,7 @@ Specify the token using the `auth-token` input argument.
163165
This form of authentication (bearer token in the request headers) is mainly used at [prefix.dev](https://prefix.dev).
164166

165167
```yml
166-
- uses: prefix-dev/setup-pixi@v0.8.2
168+
- uses: prefix-dev/setup-pixi@v0.8.3
167169
with:
168170
auth-host: prefix.dev
169171
auth-token: ${{ secrets.PREFIX_DEV_TOKEN }}
@@ -175,7 +177,7 @@ Specify the username and password using the `auth-username` and `auth-password`
175177
This form of authentication (HTTP Basic Auth) is used in some enterprise environments with [artifactory](https://jfrog.com/artifactory) for example.
176178

177179
```yml
178-
- uses: prefix-dev/setup-pixi@v0.8.2
180+
- uses: prefix-dev/setup-pixi@v0.8.3
179181
with:
180182
auth-host: custom-artifactory.com
181183
auth-username: ${{ secrets.PIXI_USERNAME }}
@@ -184,16 +186,33 @@ This form of authentication (HTTP Basic Auth) is used in some enterprise environ
184186

185187
#### Conda-token
186188

187-
Specify the conda-token using the `conda-token` input argument.
189+
Specify the conda-token using the `auth-conda-token` input argument.
188190
This form of authentication (token is encoded in URL: `https://my-quetz-instance.com/t/<token>/get/custom-channel`) is used at [anaconda.org](https://anaconda.org) or with [quetz instances](https://github.com/mamba-org/quetz).
189191

190192
```yml
191-
- uses: prefix-dev/setup-pixi@v0.8.2
193+
- uses: prefix-dev/setup-pixi@v0.8.3
192194
with:
193195
auth-host: anaconda.org # or my-quetz-instance.com
194-
conda-token: ${{ secrets.CONDA_TOKEN }}
196+
auth-conda-token: ${{ secrets.CONDA_TOKEN }}
195197
```
196198

199+
#### S3
200+
201+
Specify the S3 key pair using the `auth-access-key-id` and `auth-secret-access-key` input arguments.
202+
You can also specify the session token using the `auth-session-token` input argument.
203+
204+
```yaml
205+
- uses: prefix-dev/setup-pixi@v0.8.3
206+
with:
207+
auth-host: s3://my-s3-bucket
208+
auth-s3-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
209+
auth-s3-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
210+
# only needed if your key uses a session token
211+
auth-s3-session-token: ${{ secrets.SESSION_TOKEN }}
212+
```
213+
214+
See the [pixi documentation](https://pixi.sh/latest/advanced/s3) for more information about S3 authentication.
215+
197216
### Custom shell wrapper
198217

199218
`setup-pixi` allows you to run command inside of the pixi environment by specifying a custom shell wrapper with `shell: pixi run bash -e {0}`.
@@ -255,15 +274,15 @@ To this end, `setup-pixi` adds all environment variables set when executing `pix
255274
As a result, all installed binaries can be accessed without having to call `pixi run`.
256275

257276
```yml
258-
- uses: prefix-dev/setup-pixi@v0.8.2
277+
- uses: prefix-dev/setup-pixi@v0.8.3
259278
with:
260279
activate-environment: true
261280
```
262281

263282
If you are installing multiple environments, you will need to specify the name of the environment that you want to be activated.
264283

265284
```yml
266-
- uses: prefix-dev/setup-pixi@v0.8.2
285+
- uses: prefix-dev/setup-pixi@v0.8.3
267286
with:
268287
environments: >-
269288
py311
@@ -280,7 +299,7 @@ You can specify whether `setup-pixi` should run `pixi install --frozen` or `pixi
280299
See the [official documentation](https://prefix.dev/docs/pixi/cli#install) for more information about the `--frozen` and `--locked` flags.
281300

282301
```yml
283-
- uses: prefix-dev/setup-pixi@v0.8.2
302+
- uses: prefix-dev/setup-pixi@v0.8.3
284303
with:
285304
locked: true
286305
# or
@@ -299,7 +318,7 @@ The first one is the debug logging of the action itself.
299318
This can be enabled by running the action with the `RUNNER_DEBUG` environment variable set to `true`.
300319

301320
```yml
302-
- uses: prefix-dev/setup-pixi@v0.8.2
321+
- uses: prefix-dev/setup-pixi@v0.8.3
303322
env:
304323
RUNNER_DEBUG: true
305324
```
@@ -317,7 +336,7 @@ The second type is the debug logging of the pixi executable.
317336
This can be specified by setting the `log-level` input.
318337

319338
```yml
320-
- uses: prefix-dev/setup-pixi@v0.8.2
339+
- uses: prefix-dev/setup-pixi@v0.8.3
321340
with:
322341
# one of `q`, `default`, `v`, `vv`, or `vvv`.
323342
log-level: vvv
@@ -343,7 +362,7 @@ If nothing is specified, `post-cleanup` will default to `true`.
343362
On self-hosted runners, you also might want to alter the default pixi install location to a temporary location. You can use `pixi-bin-path: ${{ runner.temp }}/bin/pixi` to do this.
344363

345364
```yml
346-
- uses: prefix-dev/setup-pixi@v0.8.2
365+
- uses: prefix-dev/setup-pixi@v0.8.3
347366
with:
348367
post-cleanup: true
349368
# ${{ runner.temp }}\Scripts\pixi.exe on Windows
@@ -359,7 +378,7 @@ You can also use a preinstalled local version of pixi on the runner by not setti
359378
This can be overwritten by setting the `manifest-path` input argument.
360379

361380
```yml
362-
- uses: prefix-dev/setup-pixi@v0.8.2
381+
- uses: prefix-dev/setup-pixi@v0.8.3
363382
with:
364383
manifest-path: pyproject.toml
365384
```

action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ inputs:
5555
description: Password to use for authentication.
5656
auth-conda-token:
5757
description: Conda token to use for authentication.
58+
auth-s3-access-key-id:
59+
description: Access key ID to use for S3 authentication.
60+
auth-s3-secret-access-key:
61+
description: Secret access key to use for S3 authentication.
62+
auth-s3-session-token:
63+
description: Session token to use for S3 authentication.
5864
post-cleanup:
5965
description: |
6066
If the action should clean up after itself. Defaults to `true`.

dist/index.js

+39-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post.js

+34-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-pixi",
3-
"version": "0.8.2",
3+
"version": "0.8.3",
44
"private": true,
55
"description": "Action to set up the pixi package manager.",
66
"scripts": {

src/main.ts

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const pixiLogin = () => {
4242
core.debug(`Logging in to ${auth.host} with username and password`)
4343
return execute(pixiCmd(`auth login --username ${auth.username} --password ${auth.password} ${auth.host}`, false))
4444
}
45+
if ('s3AccessKeyId' in auth) {
46+
core.debug(`Logging in to ${auth.host} with s3 credentials`)
47+
const command = auth.s3SessionToken
48+
? `auth login --s3-access-key-id ${auth.s3AccessKeyId} --s3-secret-access-key ${auth.s3SecretAccessKey} --s3-session-token ${auth.s3SessionToken} ${auth.host}`
49+
: `auth login --s3-access-key-id ${auth.s3AccessKeyId} --s3-secret-access-key ${auth.s3SecretAccessKey} ${auth.host}`
50+
return execute(pixiCmd(command, false))
51+
}
4552
core.debug(`Logging in to ${auth.host} with conda token`)
4653
return execute(pixiCmd(`auth login --conda-token ${auth.condaToken} ${auth.host}`, false))
4754
})

0 commit comments

Comments
 (0)