|
| 1 | +name: Docker Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | +# [push] |
| 5 | + workflow_dispatch: |
| 6 | + schedule: |
| 7 | + - cron: '0 0 */5 * *' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: self-hosted |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Show current branch |
| 18 | + run: echo "Current branch is ${{ github.event.inputs.branch_name }}" |
| 19 | + |
| 20 | + - name: stop the AMS service |
| 21 | + run: sudo systemctl stop antmedia |
| 22 | + |
| 23 | + - name: Run Docker service |
| 24 | + run: sudo systemctl restart docker |
| 25 | + |
| 26 | + - name: Build Docker image |
| 27 | + run: docker build -f docker/Dockerfile_Process --network=host -t antmediaserver --build-arg LicenseKey="${{ secrets.ENTERPRISE_LICENSE }}" . |
| 28 | + |
| 29 | + - name: Run Docker container |
| 30 | + run: docker run --restart=always -d --name antmedia --network=host -it antmediaserver |
| 31 | + |
| 32 | + - name: Check if SSL is enabled or not |
| 33 | + run: | |
| 34 | + set -e |
| 35 | + if docker exec antmedia curl -f https://${{ secrets.CI_SSL_TEST_DOMAIN }}:5443; then |
| 36 | + echo "Endpoint is reachable." |
| 37 | + exit 1 |
| 38 | + else |
| 39 | + echo "Endpoint is not reachable, but continuing workflow." |
| 40 | + fi |
| 41 | +
|
| 42 | +# - name: Clone branch |
| 43 | +# run: | |
| 44 | +# git clone --depth=1 -b ${{ github.event.inputs.branch_name }} https://github.com/ant-media/Ant-Media-Server.git || git clone --depth=1 https://github.com/ant-media/Ant-Media-Server.git |
| 45 | + |
| 46 | + - name: Download enable_ssl.sh inside container |
| 47 | + run: docker exec antmedia wget -O /usr/local/antmedia/enable_ssl.sh https://raw.githubusercontent.com/ant-media/Ant-Media-Server/master/src/main/server/enable_ssl.sh |
| 48 | + |
| 49 | +# - name: Copy enable_ssl.sh from cloned branch to container |
| 50 | +# run: docker cp Ant-Media-Server/src/main/server/enable_ssl.sh antmedia:/usr/local/antmedia/enable_ssl.sh |
| 51 | + |
| 52 | + - name: Run enable_ssl.sh inside container |
| 53 | + run: docker exec antmedia bash /usr/local/antmedia/enable_ssl.sh -d ${{ secrets.CI_SSL_TEST_DOMAIN }} |
| 54 | + |
| 55 | + - name: Verify container is running |
| 56 | + run: | |
| 57 | + sleep 20 |
| 58 | + docker ps -f name=antmedia |
| 59 | + if [ $(docker ps -f name=antmedia --format '{{.Names}}') != "antmedia" ]; then |
| 60 | + echo "Container is not running" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Test application |
| 65 | + run: | |
| 66 | + docker exec antmedia curl -f https://${{ secrets.CI_SSL_TEST_DOMAIN }}:5443 |
| 67 | + - name: Stop and remove container |
| 68 | + if: ${{ always() }} |
| 69 | + run: | |
| 70 | + docker stop antmedia |
| 71 | + docker rm antmedia |
| 72 | + sudo systemctl start antmedia |
0 commit comments