diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml index 2596963..9c9eb1f 100644 --- a/.github/workflows/pr-preview.yml +++ b/.github/workflows/pr-preview.yml @@ -103,25 +103,28 @@ jobs: env: VERSION: ${{ env.VERSION }} run: | - # Wait for package to be available (try up to 30 times with 20s delay - total 10 minutes) for i in {1..30}; do - if curl -s -f https://test.pypi.org/pypi/socketsecurity/$VERSION/json > /dev/null; then - echo "Package ${VERSION} is now available on Test PyPI" + if pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==${VERSION}; then + echo "Package ${VERSION} is now available and installable on Test PyPI" + pip uninstall -y socketsecurity + echo "success=true" >> $GITHUB_OUTPUT exit 0 fi - echo "Attempt $i: Package not yet available, waiting 20s... (${i}/30)" + echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)" sleep 20 done - echo "Package ${VERSION} not available after 10 minutes" + echo "success=false" >> $GITHUB_OUTPUT exit 1 - name: Login to Docker Hub + if: steps.verify_package.outputs.success == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build & Push Docker Preview + if: steps.verify_package.outputs.success == 'true' uses: docker/build-push-action@v5 env: VERSION: ${{ env.VERSION }}