Update live-test.yaml #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify Dockerfile | |
on: push | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- name: Build image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: udp-echo | |
- name: Run image | |
run: docker run -p 2444:2444/udp -d udp-echo | |
- name: Get container ID | |
run: | | |
CONTAINER_ID=$(docker ps -q --filter "ancestor=udp-echo") | |
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV | |
- name: Run tests | |
run: deno test --allow-net --allow-env test.ts | |
- name: Get log file | |
run: | | |
LOG_FILES=`docker exec ${{ env.CONTAINER_ID }} bash -c 'ls /var/log/academy/'` | |
for file in "${LOG_FILES[@]}"; do | |
docker cp ${{ env.CONTAINER_ID }}:/var/log/academy/$file ./ | |
done | |
- name: Test log file | |
run: | | |
LOG_FILE=(*-udp-echo.log) | |
if [[ -f $LOG_FILE ]]; then | |
echo "Log file exists: $LOG_FILE" | |
else | |
echo "Log file does not exist: $LOG_FILE" | |
# exit 1 | |
fi | |
grep -E "^20[0-9]{2}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+[^,]+,echo:UDP,echo$" $LOG_FILE | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: metric-logs-${{ github.sha }} | |
path: | | |
*-udp-echo.log | |
- name: Login to Azure Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.CONTAINER_REGISTRY_USER }}.azurecr.io | |
username: ${{ secrets.CONTAINER_REGISTRY_USER }} | |
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ secrets.CONTAINER_REGISTRY_USER }}.azurecr.io/udp-echo |