--- name: Test docker containers on: pull_request: jobs: diff: name: Check if Dockerfile changed runs-on: ubuntu-latest outputs: did_change: ${{ steps.diff.outputs.any_changed }} steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - name: Check for changes id: diff run: | if [[ $(git diff --name-only "origin/${GITHUB_BASE_REF}" -- Dockerfile | wc -l) -gt 0 ]]; then echo "any_changed=true" >> "$GITHUB_OUTPUT" else echo "any_changed=false" >> "$GITHUB_OUTPUT" fi build: needs: [diff] if: ${{ needs.diff.outputs.did_change == 'true' }} name: Build runs-on: ubuntu-latest strategy: fail-fast: false matrix: platform: [linux/amd64, linux/arm64/v8, linux/arm/v7] dockerfile: [Dockerfile] steps: - name: Set env run: echo "mount_dir=$(mktemp -d)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 with: install: true - name: Build Docker image run: docker build --platform ${{ matrix.platform }} --load -t thelounge -f ${{ matrix.dockerfile }} . - name: Start Docker container run: docker run --platform ${{ matrix.platform }} --user "$UID" -v "${mount_dir}:/var/opt/thelounge" -d -p 9001:9000 --name thelounge thelounge - name: Check TheLounge version run: docker exec thelounge thelounge --version | grep --color=never -E "^v[0-9]\.[0-9]\.[0-9]" | cut -c 2- | grep -f /dev/stdin ${{ matrix.dockerfile }} - name: Check HTML output run: | # Retry Wait for server to start. for i in {1..10}; do (curl -sL localhost:9001 | grep "The Lounge") && s=0 && break || s=$? && sleep 1; done exit $s - name: Check for no ERROR logs run: docker logs thelounge 2>&1 | grep -vz "\[ERROR\]" - name: Check for config.js to be created in the mounted host system directory run: stat "${mount_dir}/config.js" - name: Container context if: always() run: docker exec thelounge uname -a - name: Logs if: always() run: docker logs thelounge # This job is used for branch protection rule build-check: name: Build check runs-on: ubuntu-latest needs: build if: 'failure() || cancelled()' steps: - run: exit 1