|
11 | 11 | env: |
12 | 12 | REGISTRY: ghcr.io |
13 | 13 | IMAGE_NAME: ${{ github.repository }} |
| 14 | + CIT_VERSION: "0.2.2" |
14 | 15 |
|
15 | 16 | jobs: |
16 | 17 | build: |
@@ -58,14 +59,59 @@ jobs: |
58 | 59 | "https://raw.githubusercontent.com/daemonless/daemonless/build-intermediate-v1.0.0/scripts/build-intermediate.sh" |
59 | 60 | chmod +x scripts/build-intermediate.sh |
60 | 61 |
|
61 | | - PUSH_FLAG="" |
62 | | - if [ "${{ github.event_name }}" != "pull_request" ]; then |
63 | | - PUSH_FLAG="--login --push" |
64 | | - fi |
65 | | -
|
| 62 | + # Build (no push yet) |
66 | 63 | ./scripts/build-intermediate.sh \ |
67 | 64 | --registry ${{ env.REGISTRY }} \ |
68 | 65 | --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \ |
69 | 66 | --base-version ${{ matrix.base_version }} \ |
70 | | - --tags "${{ matrix.tags }}" \ |
71 | | - $PUSH_FLAG |
| 67 | + --tags "${{ matrix.tags }}" |
| 68 | +
|
| 69 | + # Test with cit (shell mode for base images) |
| 70 | + echo "=== Running cit tests ===" |
| 71 | + fetch -qo - https://github.com/daemonless/cit/releases/download/v${{ env.CIT_VERSION }}/cit-${{ env.CIT_VERSION }}.tar.gz | tar xz |
| 72 | + ./cit-${{ env.CIT_VERSION }}/cit --setup |
| 73 | +
|
| 74 | + mkdir -p cit-results |
| 75 | + ./cit-${{ env.CIT_VERSION }}/cit ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build \ |
| 76 | + --mode shell \ |
| 77 | + --json cit-results/nginx-base-${{ matrix.base_version }}.json \ |
| 78 | + --verbose |
| 79 | +
|
| 80 | + # Push only after cit passes (non-PR) |
| 81 | + if [ "${{ github.event_name }}" != "pull_request" ]; then |
| 82 | + echo "=== Pushing image ===" |
| 83 | + ./scripts/build-intermediate.sh \ |
| 84 | + --registry ${{ env.REGISTRY }} \ |
| 85 | + --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \ |
| 86 | + --base-version ${{ matrix.base_version }} \ |
| 87 | + --tags "${{ matrix.tags }}" \ |
| 88 | + --login --push |
| 89 | + fi |
| 90 | +
|
| 91 | + - name: Upload test artifacts |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + if: always() |
| 94 | + with: |
| 95 | + name: cit-results-${{ matrix.base_version }} |
| 96 | + path: cit-results/ |
| 97 | + retention-days: 30 |
| 98 | + |
| 99 | + - name: Discord notification |
| 100 | + if: always() && (matrix.base_version == '15' || job.status == 'failure') |
| 101 | + env: |
| 102 | + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} |
| 103 | + run: | |
| 104 | + if [ "${{ job.status }}" = "success" ]; then |
| 105 | + COLOR=3066993 |
| 106 | + STATUS="✅ Success" |
| 107 | + else |
| 108 | + COLOR=15158332 |
| 109 | + STATUS="❌ Failed" |
| 110 | + fi |
| 111 | +
|
| 112 | + SHORT_SHA="${{ github.sha }}" |
| 113 | + SHORT_SHA="${SHORT_SHA:0:7}" |
| 114 | +
|
| 115 | + curl -sS -H "Content-Type: application/json" \ |
| 116 | + -d "{\"embeds\":[{\"title\":\"nginx-base:${{ matrix.base_version }} $STATUS\",\"url\":\"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",\"color\":$COLOR,\"fields\":[{\"name\":\"Commit\",\"value\":\"[$SHORT_SHA](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})\",\"inline\":true},{\"name\":\"Branch\",\"value\":\"${{ github.ref_name }}\",\"inline\":true},{\"name\":\"Registry\",\"value\":\"[ghcr.io](https://ghcr.io/${{ env.IMAGE_NAME }})\",\"inline\":true}]}]}" \ |
| 117 | + "$DISCORD_WEBHOOK" |
0 commit comments