diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 524da89..e6f245d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -38,16 +38,14 @@ on: type: string default: "" post-pr-comment: - description: >- - Generate a coverage PR comment and upload it as the 'pr-comment-coverage' artifact. For non-fork PRs the comment is also posted directly (requires pull-requests: write in the caller). Fork PRs can be handled by a workflow_run workflow that calls post-pr-comments.yml. + description: "Post or update a sticky coverage comment on the PR (requires pull-requests: write permission in the caller)" type: boolean default: false permissions: contents: read # pull-requests: write is required when post-pr-comment input is true. - # The caller workflow must grant this permission explicitly. - pull-requests: write +# The caller workflow must grant this permission explicitly. jobs: coverage: @@ -133,45 +131,22 @@ jobs: fi echo "Coverage ${COVERAGE}% meets threshold ${THRESHOLD}%" - - name: Generate coverage comment body - if: ${{ inputs.post-pr-comment && github.event_name == 'pull_request' }} - shell: bash - run: | - mkdir -p pr-comment-coverage - echo "${{ github.event.number }}" > pr-comment-coverage/pr_number - MARKER='' - TOTAL='${{ steps.coverage.outputs.total_coverage }}' - RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" - SYMBOL="$(printf '\xf0\x9f\x93\x8a')" - printf '%s\n' \ - "${MARKER}" \ - "### ${SYMBOL} Coverage Report" \ - '' \ - "**Total line coverage: ${TOTAL}%**" \ - '' \ - "[Full build artifacts](${RUN_URL})" \ - > pr-comment-coverage/body.md - - - name: Upload coverage comment artifact - if: ${{ inputs.post-pr-comment && github.event_name == 'pull_request' }} - uses: actions/upload-artifact@v7 - with: - name: pr-comment-coverage - path: pr-comment-coverage/ - - # Post directly for non-fork PRs (instant feedback). - # Fork PRs lack write permissions and cannot directly post comments. - # they can be handled by a separate workflow_run workflow that calls - # post-pr-comments.yml. - name: Post coverage comment on PR - if: >- - inputs.post-pr-comment && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - uses: actions/github-script@v9 + if: ${{ inputs.post-pr-comment && github.event_name == 'pull_request' }} + uses: actions/github-script@v7 with: script: | - const fs = require('fs'); - const body = fs.readFileSync('pr-comment-coverage/body.md', 'utf8'); const marker = ''; + const total = '${{ steps.coverage.outputs.total_coverage }}'; + const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; + const body = [ + marker, + '### \uD83D\uDCCA Coverage Report', + '', + `**Total line coverage: ${total}%**`, + '', + `[Full build artifacts](${runUrl})`, + ].join('\n'); const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, diff --git a/.github/workflows/first-interaction.yml b/.github/workflows/first-interaction.yml new file mode 100644 index 0000000..5faf314 --- /dev/null +++ b/.github/workflows/first-interaction.yml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 + +name: First Interaction + +on: + pull_request_target: + types: [opened] + issues: + types: [opened] + +jobs: + first-interaction: + runs-on: ubuntu-26.04 + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: | + Welcome, and thanks for opening your first issue! + + Please make sure you've reviewed our [contribution guidelines](https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/blob/main/CONTRIBUTING.md) + and that your issue includes enough context for maintainers to understand the problem. + + The team will get back to you as soon as possible. + pr-message: | + Thanks for your first pull request! + + A few things to keep in mind: + - Make sure CI checks pass before requesting a review. + - Eclipse projects require a **DCO sign-off** on every commit: + use `git commit -s` or add `Signed-off-by: Your Name ` manually. + - See [CONTRIBUTING.md](https://github.com/eclipse-opensovd/opensovd/blob/main/CONTRIBUTING.md) for details. + + A maintainer will review your PR shortly. Welcome to the project!