Skip to content

Commit ce09f04

Browse files
committed
ci: add testing
1 parent 408498e commit ce09f04

2 files changed

Lines changed: 53 additions & 7 deletions

File tree

File renamed without changes.

.github/workflows/build.yml

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
env:
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: ${{ github.repository }}
14+
CIT_VERSION: "0.2.2"
1415

1516
jobs:
1617
build:
@@ -58,14 +59,59 @@ jobs:
5859
"https://raw.githubusercontent.com/daemonless/daemonless/build-intermediate-v1.0.0/scripts/build-intermediate.sh"
5960
chmod +x scripts/build-intermediate.sh
6061
61-
PUSH_FLAG=""
62-
if [ "${{ github.event_name }}" != "pull_request" ]; then
63-
PUSH_FLAG="--login --push"
64-
fi
65-
62+
# Build (no push yet)
6663
./scripts/build-intermediate.sh \
6764
--registry ${{ env.REGISTRY }} \
6865
--image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} \
6966
--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

Comments
 (0)