Skip to content

Commit

Permalink
Merge pull request #14 from ADACS-Australia/ADACS_MAP_AMoller_2023A
Browse files Browse the repository at this point in the history
Turn off workflow publishing logic if secrets are not defined
  • Loading branch information
gbpoole authored Nov 28, 2023
2 parents eaf1f1b + 94dfaaf commit ac48fc1
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ on:
release:
types: [created]

# These are needed because secrets can not be used in 'if' expressions
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
RTD_WEBHOOK_URL: ${{ secrets.RTD_WEBHOOK_URL }}
RTD_WEBHOOK_TOKEN: ${{ secrets.RTD_WEBHOOK_TOKEN }}

jobs:

# Useful for workflow debugging
Expand Down Expand Up @@ -56,32 +63,32 @@ jobs:
# Configure repository for test.PyPI
- name: Configure Poetry for test.PyPI
if: "github.event.release.prerelease"
if: "github.event.release.prerelease && env.TEST_PYPI_TOKEN"
run: |
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }}
# Configure repository for PyPI
- name: Configure Poetry for PyPI
if: "!github.event.release.prerelease"
if: "!github.event.release.prerelease && env.PYPI_TOKEN"
run: |
poetry config http-basic.pypi "__token__" ${{ secrets.PYPI_TOKEN }}
# Publish docs
- name: Trigger RTDs build
if: "!github.event.release.prerelease"
if: "!github.event.release.prerelease && env.RTD_WEBHOOK_URL && env.RTD_WEBHOOK_TOKEN"
run: |
curl -X POST \
-d "token=${{ secrets.RTD_WEBHOOK_TOKEN }}" \
${{ secrets.RTD_WEBHOOK_URL }}
# Publish project to test.PyPI
# - name: Publish to test.PyPI
# if: "github.event.release.prerelease"
# run: poetry publish --build -r testpypi
#
# # ... else publish project to PyPI
# - name: Publish to PyPI
# if: "!github.event.release.prerelease"
# run: poetry publish --build
- name: Publish to test.PyPI
if: "github.event.release.prerelease && env.TEST_PYPI_TOKEN"
run: poetry publish --build -r testpypi

# ... else publish project to PyPI
- name: Publish to PyPI
if: "!github.event.release.prerelease && env.PYPI_TOKEN"
run: poetry publish --build

0 comments on commit ac48fc1

Please sign in to comment.