Update publish.yml to use gh (#15686)

This commit is contained in:
Glenn Jocher 2024-08-20 16:01:41 +08:00 committed by GitHub
parent b63af4cbcc
commit 97db4abb1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 8 deletions

View file

@ -22,7 +22,7 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: ${{ github.event.pull_request_target.head.repo.full_name || github.repository }} repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref || github.ref }} ref: ${{ github.head_ref || github.ref }}
fetch-depth: 0 fetch-depth: 0

View file

@ -172,16 +172,19 @@ jobs:
python -m build python -m build
python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN
- name: Extract PR Details - name: Extract PR Details
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
run: | run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then # Check if the event is a pull request or pull_request_target
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}) if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "pull_request_target" ]; then
PR_NUMBER=${{ github.event.pull_request.number }} PR_NUMBER=${{ github.event.pull_request.number }}
PR_TITLE=$(echo $PR_JSON | jq -r '.title') PR_TITLE=$(gh pr view $PR_NUMBER --json title --jq '.title')
else else
# Use gh to find the PR associated with the commit
COMMIT_SHA=${{ github.event.after }} COMMIT_SHA=${{ github.event.after }}
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/search/issues?q=repo:${{ github.repository }}+is:pr+is:merged+sha:$COMMIT_SHA") PR_JSON=$(gh pr list --search "${COMMIT_SHA}" --state merged --json number,title --jq '.[0]')
PR_NUMBER=$(echo $PR_JSON | jq -r '.items[0].number') PR_NUMBER=$(echo $PR_JSON | jq -r '.number')
PR_TITLE=$(echo $PR_JSON | jq -r '.items[0].title') PR_TITLE=$(echo $PR_JSON | jq -r '.title')
fi fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV

View file

@ -18,7 +18,6 @@ keywords: Ultralytics HUB, YOLO models, train YOLO, YOLOv5, YOLOv8, object detec
<a href="https://docs.ultralytics.com/pt/hub/">Português</a> | <a href="https://docs.ultralytics.com/pt/hub/">Português</a> |
<a href="https://docs.ultralytics.com/tr/hub/">Türkçe</a> | <a href="https://docs.ultralytics.com/tr/hub/">Türkçe</a> |
<a href="https://docs.ultralytics.com/vi/hub/">Tiếng Việt</a> | <a href="https://docs.ultralytics.com/vi/hub/">Tiếng Việt</a> |
<a href="https://docs.ultralytics.com/hi/hub/">हिन्दी</a> |
<a href="https://docs.ultralytics.com/ar/hub/">العربية</a> <a href="https://docs.ultralytics.com/ar/hub/">العربية</a>
<br> <br>
<br> <br>