Skip to content

Commit 567ed0e

Browse files
authored
Add check for secrets and skip steps - stop running ci on new checkin (#22)
1 parent dcf674e commit 567ed0e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

.github/workflows/build.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ jobs:
1212
os: [macos-latest, ubuntu-18.04, windows-latest]
1313

1414
steps:
15+
- name: Cancel previous runs on the same branch
16+
uses: styfle/[email protected]
17+
with:
18+
access_token: ${{ github.token }}
19+
1520
- uses: actions/checkout@v1
1621
with:
1722
fetch-depth: 0
@@ -22,6 +27,16 @@ jobs:
2227
with:
2328
python-version: '3.7'
2429

30+
- name: Test for secrets access
31+
id: check_secrets
32+
shell: bash
33+
run: |
34+
unset HAS_SECRET
35+
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
36+
echo ::set-output name=HAS_SECRET::${HAS_SECRET}
37+
env:
38+
SECRET: "${{ secrets.test_pypi_password }}"
39+
2540
- name: Install cibuildwheel
2641
run: |
2742
python -m pip install --upgrade pip
@@ -100,6 +115,7 @@ jobs:
100115
run: pip install twine
101116

102117
- name: Publish distribution to Test PyPI
118+
if: steps.check_secrets.outputs.HAS_SECRET
103119
env:
104120
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
105121
TWINE_USERNAME: __token__
@@ -108,7 +124,7 @@ jobs:
108124
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'
109125

110126
- name: Publish distribution to PyPI
111-
if: startsWith(github.event.ref, 'refs/tags')
127+
if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET
112128
env:
113129
TWINE_USERNAME: __token__
114130
TWINE_NON_INTERACTIVE: 1

0 commit comments

Comments
 (0)