Skip to content

Commit 5c56087

Browse files
committed
GH Actions: special case Dependabot PRs for Coveralls
Follow up on PR 468. Turns out Dependabot PRs do not have access to secrets with the exception of (read-only) access to the `GITHUB_TOKEN`. As the coverage test runs and the Coveralls status are required builds, this blocks Dependabot PRs from being merged without overruling the required statuses. As I'd like to avoid that situation, I'm special casing Dependabot PRs for the token selection. Unfortunately using a condition like `${{ github.actor != 'dependabot[bot]' || secrets.COVERALLS_TOKEN && secrets.GITHUB_TOKEN }}` won't work when it involves secrets, so we need to use duplicate steps to get round this. Refs: * lemurheavy/coveralls-public 1721 * https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
1 parent aa23fbf commit 5c56087

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/test.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,23 +363,45 @@ jobs:
363363
if: ${{ success() }}
364364
run: composer global require php-coveralls/php-coveralls:"^2.5.3" --no-interaction
365365

366-
- name: Upload coverage results to Coveralls
367-
if: ${{ success() }}
366+
- name: Upload coverage results to Coveralls (normal)
367+
if: ${{ success() && github.actor != 'dependabot[bot]' }}
368368
env:
369369
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
370370
COVERALLS_PARALLEL: true
371371
COVERALLS_FLAG_NAME: php-${{ matrix.php }}-phpcs-${{ matrix.phpcs_version }}
372372
run: php-coveralls -v -x build/logs/clover.xml
373373

374+
# Dependabot does not have access to secrets, other than the GH token.
375+
# Ref: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
376+
# Ref: https://github.com/lemurheavy/coveralls-public/issues/1721
377+
- name: Upload coverage results to Coveralls (Dependabot)
378+
if: ${{ success() && github.actor == 'dependabot[bot]' }}
379+
env:
380+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
381+
COVERALLS_PARALLEL: true
382+
COVERALLS_FLAG_NAME: php-${{ matrix.php }}-phpcs-${{ matrix.phpcs_version }}
383+
run: php-coveralls -v -x build/logs/clover.xml
384+
374385
coveralls-finish:
375386
needs: coverage
376387
if: always() && needs.coverage.result == 'success'
377388

378389
runs-on: ubuntu-latest
379390

380391
steps:
381-
- name: Coveralls Finished
392+
- name: Coveralls Finished (normal)
393+
if: ${{ github.actor != 'dependabot[bot]' }}
382394
uses: coverallsapp/github-action@v2
383395
with:
384396
github-token: ${{ secrets.COVERALLS_TOKEN }}
385397
parallel-finished: true
398+
399+
# Dependabot does not have access to secrets, other than the GH token.
400+
# Ref: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
401+
# Ref: https://github.com/lemurheavy/coveralls-public/issues/1721
402+
- name: Coveralls Finished (Dependabot)
403+
if: ${{ github.actor == 'dependabot[bot]' }}
404+
uses: coverallsapp/github-action@v2
405+
with:
406+
github-token: ${{ secrets.GITHUB_TOKEN }}
407+
parallel-finished: true

0 commit comments

Comments
 (0)