|
1 | | -name: D10 - Security Review |
| 1 | +name: Drupal - Security Review |
2 | 2 | # Required Secrets (same across projects): |
3 | 3 | # EMAIL_USERNAME: Gmail address for sending notifications (i.e. [email protected]) |
4 | 4 | # EMAIL_PASSWORD: Gmail App Password (no spaces) |
| 5 | +# COMPOSER_GITHUB_TOKEN: (Conditional) GitHub Personal Access Token ("PAT") with 'repo' scope - only needed if composer.json has private VCS dependencies. A classic PAT is recommended. More info here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens |
5 | 6 | # **Details are stored in the 1password vault named "Production".** |
6 | 7 | # |
7 | 8 | # Required Variables (unique per project): |
|
19 | 20 | - name: "Checkout code" |
20 | 21 | uses: actions/checkout@v4 |
21 | 22 |
|
| 23 | + - name: Check if private composer dependencies exist |
| 24 | + id: check_private_deps |
| 25 | + run: | |
| 26 | + if grep -q '"type"[[:space:]]*:[[:space:]]*"vcs"' composer.json; then |
| 27 | + echo "has_private_deps=true" >> $GITHUB_OUTPUT |
| 28 | + echo "⚠️ This project uses private VCS dependencies" |
| 29 | + else |
| 30 | + echo "has_private_deps=false" >> $GITHUB_OUTPUT |
| 31 | + echo "✅ This project uses only public dependencies" |
| 32 | + fi |
| 33 | +
|
| 34 | + - name: Validate composer authentication |
| 35 | + if: steps.check_private_deps.outputs.has_private_deps == 'true' && !secrets.COMPOSER_GITHUB_TOKEN |
| 36 | + run: | |
| 37 | + echo "::error::This project requires private composer dependencies but COMPOSER_GITHUB_TOKEN secret is not set." |
| 38 | + echo "::error::Please add COMPOSER_GITHUB_TOKEN secret with a GitHub Personal Access Token that has 'repo' scope." |
| 39 | + echo "::error::Generate at: https://github.com/settings/tokens" |
| 40 | + exit 1 |
| 41 | +
|
22 | 42 | - name: Install PHP with extensions |
23 | 43 | uses: shivammathur/[email protected] |
24 | 44 | with: |
|
27 | 47 | tools: composer:v2 |
28 | 48 |
|
29 | 49 | - name: "Composer install" |
| 50 | + env: |
| 51 | + COMPOSER_AUTH: ${{ secrets.COMPOSER_GITHUB_TOKEN && format('{{"github-oauth":{{"github.com":"{0}"}}}}', secrets.COMPOSER_GITHUB_TOKEN) || '{}' }} |
30 | 52 | |
31 | 53 | with: |
32 | 54 | composer-options: "--prefer-dist" |
|
0 commit comments