diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 0000000000..b761ff2bb1 --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,21 @@ +name: Auto assign PR author + +on: + issues: + types: [ opened, reopened ] + pull_request_target: + types: [ opened, reopened, synchronize ] + workflow_call: + +permissions: + issues: write + pull-requests: write + +jobs: + assign-author: + runs-on: ubuntu-latest + steps: + - name: Auto assign PR author + uses: toshimaru/auto-author-assign@v3.0.1 + with: + repo-token: ${{ github.token }} diff --git a/.github/workflows/label-sync.yml b/.github/workflows/label-sync.yml new file mode 100644 index 0000000000..def93c28ff --- /dev/null +++ b/.github/workflows/label-sync.yml @@ -0,0 +1,53 @@ +name: Pull Request Label Sync + +on: + pull_request_target: + types: [opened, reopened, synchronize] + pull_request: + types: [opened, reopened, synchronize] + workflow_call: + inputs: + copy_issue_labels: + type: boolean + default: true + description: "Copy labels from linked issue" + +permissions: + contents: read + pull-requests: write + +jobs: + copy-issue-labels: + if: inputs.copy_issue_labels == true || github.event_name != 'workflow_call' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Extract issue number from PR + id: extract-issue + env: + BODY: ${{ github.event.pull_request.body }} + TITLE: ${{ github.event.pull_request.title }} + run: | + ISSUE=$(echo "$TITLE $BODY" | \ + grep -oiE '(closes|fixes|resolves|addresses)\s+#[[:digit:]]+' | \ + grep -oE '#[[:digit:]]+' | head -1 | tr -d '#') + + if [ -n "$ISSUE" ]; then + echo "issue_number=$ISSUE" >> "$GITHUB_OUTPUT" + fi + + - name: Copy labels from issue to PR + if: steps.extract-issue.outputs.issue_number != '' + run: | + LABELS=$(gh issue view "$ISSUE_NUM" --repo "$REPO" --json labels --jq '.labels[].name') + + for label in $LABELS; do + gh pr edit "$PR_NUM" --repo "$REPO" --add-label "$label" 2>/dev/null || true + done + env: + ISSUE_NUM: ${{ steps.extract-issue.outputs.issue_number }} + PR_NUM: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml index 8f71b6473e..6b312d49d9 100644 --- a/.github/workflows/reports.yml +++ b/.github/workflows/reports.yml @@ -22,25 +22,23 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - name: Cache Composer dependencies uses: actions/cache@v5 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - ${{ runner.os }}-composer- + path: /tmp/composer-cache + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- - name: Install dependencies uses: php-actions/composer@v6 env: COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }' + COMPOSER_CACHE_DIR: /tmp/composer-cache with: php_version: '8.3' + command: 'install' + args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts' - name: Generate reports uses: php-actions/composer@v6 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b31c681d49..288fb66a35 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,25 +38,29 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - name: Cache Composer dependencies uses: actions/cache@v5 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - ${{ runner.os }}-composer- + path: /tmp/composer-cache + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- - name: Install dependencies uses: php-actions/composer@v6 env: COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }' + COMPOSER_CACHE_DIR: /tmp/composer-cache + with: + php_version: ${{ matrix.php-version }} + command: 'install' + args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts' + + - name: Composer Audit + uses: php-actions/composer@v6 with: php_version: ${{ matrix.php-version }} + command: 'audit' - name: Resolve minimum coverage id: minimum-coverage diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml index 5e2fda239e..c2c750df5c 100644 --- a/.github/workflows/wiki.yml +++ b/.github/workflows/wiki.yml @@ -26,15 +26,11 @@ jobs: submodules: recursive fetch-depth: 0 - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - - name: Cache Composer dependencies uses: actions/cache@v5 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + path: /tmp/composer-cache + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-composer- @@ -42,8 +38,11 @@ jobs: uses: php-actions/composer@v6 env: COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }' + COMPOSER_CACHE_DIR: /tmp/composer-cache with: php_version: '8.3' + command: 'install' + args: '--prefer-dist --no-progress --no-interaction --no-plugins --no-scripts' - name: Create Docs Markdown uses: php-actions/composer@v6 @@ -80,4 +79,4 @@ jobs: message: "Update wiki submodule pointer" default_author: github_actions pull: "--rebase --autostash" - push: true \ No newline at end of file + push: true diff --git a/resources/github-actions/auto-assign.yml b/resources/github-actions/auto-assign.yml new file mode 100644 index 0000000000..14dfb4b3ff --- /dev/null +++ b/resources/github-actions/auto-assign.yml @@ -0,0 +1,14 @@ +name: Auto assign + +on: + pull_request_target: + types: [opened, reopened, synchronize] + issues: + types: [opened, reopened] + +jobs: + auto-assign: + permissions: + issues: write + pull-requests: write + uses: php-fast-forward/dev-tools/.github/workflows/auto-assign.yml@main diff --git a/resources/github-actions/label-sync.yml b/resources/github-actions/label-sync.yml new file mode 100644 index 0000000000..e99f9bb703 --- /dev/null +++ b/resources/github-actions/label-sync.yml @@ -0,0 +1,13 @@ +name: Label sync + +on: + pull_request_target: + types: [opened, reopened, synchronize] + issues: + types: [opened, reopened] + +jobs: + label-sync: + permissions: + pull-requests: write + uses: php-fast-forward/dev-tools/.github/workflows/label-sync.yml@main \ No newline at end of file