diff --git a/.github/workflows/annotate.yml b/.github/workflows/annotate.yml new file mode 100644 index 0000000..b835a82 --- /dev/null +++ b/.github/workflows/annotate.yml @@ -0,0 +1,59 @@ +name: annotate + +on: + pull_request: + branches: [ "*" ] + +jobs: + update-docblocks: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install jq + run: sudo apt-get install -y jq + + - name: Extract homepage from composer.json + id: composer + run: | + if [ -f "composer.json" ]; then + HOMEPAGE=$(jq -r '.homepage // empty' composer.json) + if [ ! -z "$HOMEPAGE" ]; then + echo "homepage=$HOMEPAGE" >> $GITHUB_OUTPUT + else + echo "Error: homepage not found in composer.json" + exit 1 + fi + else + echo "Error: composer.json not found" + exit 1 + fi + + - name: Run DocBlock Annotator + run: docker run -v ${{ github.workspace }}/src:/app/run --rm davidsmith3/docblock-annotator-cli docblock-annotator-cli:update /app/run "@link ${{ steps.composer.outputs.homepage }}" + + - name: Check for changes + id: git-check + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "changes=false" >> $GITHUB_OUTPUT + fi + + - name: Commit changes + if: steps.git-check.outputs.changes == 'true' + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add . + git commit -m "Update docblocks." + git pull --rebase origin ${{ github.head_ref }} + git push origin HEAD:${{ github.head_ref }} \ No newline at end of file diff --git a/.github/workflows/backwards_compatibility.yml b/.github/workflows/backwards_compatibility.yml index 714dc4b..63c45e0 100644 --- a/.github/workflows/backwards_compatibility.yml +++ b/.github/workflows/backwards_compatibility.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: ${{ github.event.pull_request.base.ref != 'main' }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set safe directory diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index fba096c..394444f 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/composer_require_checker.yml b/.github/workflows/composer_require_checker.yml index b6f6ce3..db4b123 100644 --- a/.github/workflows/composer_require_checker.yml +++ b/.github/workflows/composer_require_checker.yml @@ -14,7 +14,7 @@ jobs: php-version: [ "8.2" ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Set safe directory diff --git a/.github/workflows/docblock_update.yml b/.github/workflows/docblock_update.yml deleted file mode 100644 index ec73536..0000000 --- a/.github/workflows/docblock_update.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: docblock_update - -on: - pull_request: - branches: [ "*" ] - -jobs: - update-docblocks: - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - name: Checkout code - uses: actions/checkout@v5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.head_ref || github.ref }} - fetch-depth: 0 - - - name: Update docblocks - run: | - set -e - SOURCE_URL=$(jq -r '.support.source' composer.json) - if [ ! -d ./src ]; then - echo "Source directory ./src does not exist!" - exit 1 - fi - docker run --rm -v "$PWD/src:/app/run" davidsmith3/docblock-annotator-cli \ - docblock-annotator-cli:update-directory /app/run "@link $SOURCE_URL" - - - name: Commit and push changes (if any) - run: | - set -e - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add -A - if ! git diff --cached --quiet; then - git commit -m "Update docblocks with @link annotations" --no-verify - git push - else - echo "No changes to commit." - fi \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1007c5b..d53742e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: fetch-depth: 0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b2d670..5376057 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: php-version: [ "8.2" ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Create .env run: touch .env