|
16 | 16 | required: false |
17 | 17 | default: "" |
18 | 18 | type: string |
| 19 | + tag: |
| 20 | + description: "Tag of the image to scan. By default 'latest'" |
| 21 | + required: false |
| 22 | + default: "latest" |
| 23 | + type: string |
19 | 24 | only-high-critical: |
20 | 25 | description: "Scope only HIGH + CRITICAL" |
21 | 26 | required: false |
@@ -50,51 +55,40 @@ jobs: |
50 | 55 | permissions: |
51 | 56 | packages: read |
52 | 57 | outputs: |
53 | | - ghcr-packages: ${{ steps.pkgs.outputs.ghcr-packages }} |
| 58 | + packages: ${{ steps.ghcr.outputs.packages }} |
| 59 | + has-packages: ${{ steps.ghcr.outputs.has-packages }} |
54 | 60 | steps: |
55 | | - - name: Show raw GHCR response |
56 | | - id: pkgs |
| 61 | + - name: List GHCR packages for this repo |
| 62 | + id: ghcr |
| 63 | + uses: Netcracker/qubership-workflow-hub/actions/ghcr-discover-repo-packages@v2.0.3 |
57 | 64 | env: |
58 | | - GH_TOKEN: ${{ secrets.GH_PAT_PACKAGES }} |
59 | | - OWNER: ${{ github.repository_owner }} |
60 | | - run: | |
61 | | - api_url="https://api.github.com/users/${OWNER}/packages?package_type=container" |
62 | | - echo "Request: $api_url" |
63 | | -
|
64 | | - response=$(curl -sS \ |
65 | | - -H "Authorization: Bearer $GH_TOKEN" \ |
66 | | - -H "Accept: application/vnd.github+json" \ |
67 | | - "$api_url") |
| 65 | + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |
68 | 66 |
|
69 | | - packages=$(echo "$response" | jq -c --arg owner "$OWNER" ' |
70 | | - [.[] |
71 | | - | select(.repository.full_name == "nookyo/qubership-monitoring-operator") |
72 | | - | { name: .name, repository: .repository.name, full_name: .repository.full_name, path: "ghcr.io/\($owner)/\(.name)" } |
73 | | - ] |
74 | | - ') |
| 67 | + - name: Print packages |
| 68 | + run: echo '${{ steps.ghcr.outputs.packages }}' | jq '.' |
75 | 69 |
|
76 | | - echo "ghcr-packages=$packages" >> "$GITHUB_OUTPUT" |
77 | | - echo "Raw response:" |
78 | | - echo "$packages" |
| 70 | + - name: Continue only if repo has GHCR packages |
| 71 | + if: ${{ steps.ghcr.outputs.has-packages == 'true' }} |
| 72 | + run: echo "Packages found!" |
79 | 73 |
|
80 | 74 | security-scan-matrix: |
81 | 75 | needs: debug-packages |
82 | 76 | if: ${{ inputs.image == '' || inputs.image == null }} |
83 | 77 | strategy: |
84 | 78 | matrix: |
85 | | - package: ${{ fromJson(needs.debug-packages.outputs.ghcr-packages) }} |
| 79 | + package: ${{ fromJson(needs.debug-packages.outputs.packages) }} |
86 | 80 |
|
87 | 81 | name: "Run Security Scan (matrix)" |
88 | | - uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main |
| 82 | + uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.3 |
89 | 83 | with: |
90 | 84 | target: ${{ inputs.target || 'docker' }} |
91 | | - image: ${{ format('{0}:main', matrix.package.path) }} |
| 85 | + image: ${{ format('{0}:{1}', matrix.package.path, inputs.tag || 'latest') }} |
92 | 86 |
|
93 | 87 | security-scan-single: |
94 | 88 | needs: debug-packages |
95 | 89 | if: ${{ inputs.image != '' && inputs.image != null }} |
96 | 90 | name: "Run Security Scan (single image)" |
97 | | - uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@main |
| 91 | + uses: netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.3 |
98 | 92 | with: |
99 | 93 | target: ${{ inputs.target || 'docker' }} |
100 | 94 | image: ${{ inputs.image }} |
|
0 commit comments