ci: add downloadable Docker image with container smoke tests
build-image / build-push (push) Failing after 30s
build-image / build-push (push) Failing after 30s
This commit is contained in:
1 parent
ebb2d1d792
commit
c58953b736
1 file changed
+50
@@ -0,0 +1,50 @@
|
||||
name: build-download
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build-download:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build image
|
||||
run: |
|
||||
docker build -t git.jf.eng.br/jfeng/hotspot:latest -t git.jf.eng.br/jfeng/hotspot:${{ github.sha }} ./backend
|
||||
|
||||
- name: Smoke test image
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
container=$(docker run -d git.jf.eng.br/jfeng/hotspot:${{ github.sha }})
|
||||
trap 'docker rm -f "$container" >/dev/null' EXIT
|
||||
for attempt in {1..15}; do
|
||||
if docker exec "$container" node -e "fetch('http://127.0.0.1:3000/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"; then
|
||||
docker exec "$container" node -e "Promise.all(['/api/plans','/admin'].map(p=>fetch('http://127.0.0.1:3000'+p).then(r=>{if(!r.ok)throw Error(p)}))).catch(()=>process.exit(1))"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
docker logs "$container"
|
||||
exit 1
|
||||
|
||||
- name: Export Docker archive
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
docker save git.jf.eng.br/jfeng/hotspot:latest git.jf.eng.br/jfeng/hotspot:${{ github.sha }} | gzip > pix-hotspot-image.tar.gz
|
||||
sha256sum pix-hotspot-image.tar.gz > pix-hotspot-image.tar.gz.sha256
|
||||
|
||||
- name: Upload image for ZimaOS
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: pix-hotspot-zimaos
|
||||
path: |
|
||||
pix-hotspot-image.tar.gz
|
||||
pix-hotspot-image.tar.gz.sha256
|
||||
retention-days: 7
|
||||
Reference in new issue
Block a user