Skip to content

Commit a0054d1

Browse files
committed
Use environments for additional deployment safety
Signed-off-by: Keith Battocchi <[email protected]>
1 parent 6d2bdfc commit a0054d1

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ jobs:
346346
uses: ./.github/workflows/publish-package.yml
347347
with:
348348
publish: false
349-
repository: testpypi
349+
environment: test
350350
# don't have access to env context here for some reason
351351
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || null }}
352352
# can't use env context here so need to duplicate expression, but these are true boolean values so don't need extra string logic

.github/workflows/publish-documentation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ jobs:
9191

9292
publish-docs:
9393
name: Publish documentation
94-
runs-on: ubuntu-latest
9594
needs: create_docs
9695
permissions:
9796
id-token: write # needed to publish to Azure
97+
environment: ${{ inputs.environment }}
9898
if: ${{ inputs.publish }}
99+
runs-on: ubuntu-latest
99100
steps:
100101
- name: Download docs artifact
101102
uses: actions/download-artifact@v3

.github/workflows/publish-package.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ on:
88
required: false
99
default: true
1010
type: boolean
11-
repository:
11+
environment:
1212
description: 'Whether to publish to production PyPI or test PyPI'
1313
required: false
14-
default: pypi
14+
default: prod
1515
type: choice
16-
options: [pypi, testpypi]
16+
options: [prod, test]
1717
ref:
1818
description: 'The git ref to build the package for'
1919
required: false
@@ -34,10 +34,10 @@ on:
3434
default: true
3535
type: boolean
3636
# choice type only supported for workflow_dispatch, not workflow_call
37-
repository:
37+
environment:
3838
description: 'Whether to publish to production PyPI or test PyPI'
3939
required: false
40-
default: pypi
40+
default: prod
4141
type: string
4242
ref:
4343
description: 'The git ref to build the package for'
@@ -119,6 +119,7 @@ jobs:
119119
needs: [merge]
120120
permissions:
121121
id-token: write
122+
environment: ${{ inputs.environment }}
122123
if: ${{ inputs.publish }}
123124
runs-on: ubuntu-latest
124125
steps:
@@ -130,4 +131,4 @@ jobs:
130131
- name: Upload wheels and sdist to package index
131132
uses: pypa/gh-action-pypi-publish@release/v1
132133
with:
133-
repository-url: ${{ inputs.repository == 'testpypi' && 'https://test.pypi.org/legacy/' || '' }}
134+
repository-url: ${{ inputs.environment == 'test' && 'https://test.pypi.org/legacy/' || '' }}

0 commit comments

Comments
 (0)