Update to 2.10.0 #6
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: Docker Image Build/Push and Development Test | |
on: | |
pull_request: | |
paths-ignore: | |
- '**/README.md' | |
- '**/.github/**' | |
- '**/package.sh' | |
check_suite: | |
types: | |
- requested | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-22.04 | |
env: | |
DOCKER_URL: antmedia/enterprise | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download latest.zip | |
run: wget --quiet ${{ secrets.LATEST_URL }} | |
- name: Download Dockerfile | |
run: wget --quiet https://raw.githubusercontent.com/ant-media/Scripts/master/docker/Dockerfile_Process -O Dockerfile | |
- name: Read version from VERSION file | |
id: read-version | |
run: echo "::set-output name=version::$(cat VERSION)" | |
- name: Set image name | |
id: set-image-name | |
run: echo "IMAGE_NAME=${{ env.DOCKER_URL }}" >> $GITHUB_ENV | |
- name: Build Docker image | |
run: docker build --network=host -t antmediaserver:${{ steps.read-version.outputs.version }} --build-arg AntMediaServer=latest.zip . | |
- name: Tag Docker image | |
run: | | |
docker tag $(docker images --format "{{.ID}}" --filter "reference=antmediaserver:${{ steps.read-version.outputs.version }}") ${{ env.IMAGE_NAME }}:${{ steps.read-version.outputs.version }} | |
docker tag $(docker images --format "{{.ID}}" --filter "reference=antmediaserver:${{ steps.read-version.outputs.version }}") ${{ env.IMAGE_NAME }}:latest | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push Docker image | |
run: | | |
docker push ${{ env.IMAGE_NAME }}:${{ steps.read-version.outputs.version }} | |
docker push ${{ env.IMAGE_NAME }}:latest | |
build: | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Run the build package | |
run: bash package.sh | |
shell: bash | |
- name: Get version | |
id: version | |
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT | |
- name: Get commit message | |
id: commit_message | |
run: | | |
commit_message=$(git log --format=%B -n 1 ${{ github.event.pull_request.head.sha }}) | |
echo "::set-output name=commit_message::$commit_message" | |
- name: Commit files | |
run: | | |
git config --global user.name ${{ github.actor }} | |
git config --global user.email "[email protected]" | |
git add * | |
git commit -m "${{ steps.commit_message.outputs.commit_message || 'Auto-commit changes' }}" | |
- name: Push changes | |
run: | | |
git remote set-url origin https://github.com/ant-media/helm.git | |
git config --global user.name ${{ github.actor }} | |
git config --global user.email "[email protected]" | |
git push origin HEAD:${GITHUB_HEAD_REF} | |
test_local: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Get version | |
id: version | |
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT | |
- name: Set up Minikube | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y conntrack | |
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | |
sudo install minikube-linux-amd64 /usr/local/bin/minikube | |
- name: Stop/Start Minikube | |
run: | | |
sudo usermod -aG docker $USER | |
newgrp docker | |
sudo systemctl restart docker | |
minikube stop | |
minikube start --driver=docker | |
- name: Install Helm | |
run: | | |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash | |
- name: Install dependencies | |
run: | | |
helm dependency update . | |
- name: Lint Helm chart | |
run: | | |
helm lint . | |
- name: Deploy Helm chart to Minikube | |
run: | | |
ls -alh | |
helm install antmedia antmedia-${{ steps.version.outputs.version }}.tgz --set origin=origin.antmedia.cloud --namespace antmedia --create-namespace | |
- name: Wait for containers to be ready | |
run: | | |
while true; do | |
STATUS=$(kubectl get pods -n antmedia -o jsonpath='{.items[0].status.containerStatuses[0].ready}') | |
if [ "$STATUS" == "true" ]; then | |
break | |
fi | |
sleep 5 | |
done | |
- name: Get Minikube IP | |
id: minikube_ip | |
run: echo "::set-output name=ip::$(minikube ip)" | |
- name: Test pod using curl | |
id: curl_result | |
run: | | |
sleep 30 | |
status_code=$(curl -s -o /dev/null -w "%{http_code}" http://${{ steps.minikube_ip.outputs.ip }}:5080) | |
echo "::set-output name=status_code::$status_code" | |
- name: Check curl result | |
run: | | |
if [[ "${{ steps.curl_result.outputs.status_code }}" -eq 200 ]]; then | |
echo "Ant Media Server is running successfully." | |
else | |
echo "Ant Media Server is not accessible. HTTP status code: ${{ steps.curl_result.outputs.status_code }}" | |
exit 1 | |
fi | |
- name: Download Sample MP4 Video | |
run: | | |
wget https://raw.githubusercontent.com/ant-media/Ant-Media-Server/master/src/test/resources/sample_MP4_480.mp4 | |
- name: Install FFmpeg and Check RTMP Stream | |
run: | | |
pod_ip_address=$(kubectl get pods -l app=ant-media-origin -o wide -n antmedia -o custom-columns=IP:.status.podIP --no-headers) | |
sudo apt-get update | |
sudo apt-get install -y ffmpeg | |
ffmpeg -re -i sample_MP4_480.mp4 -t 10 -c copy -f flv rtmp://"$pod_ip_address"/WebRTCAppEE/stream1 | |
# - name: Check Playback | |
# run: | | |
# ffplay "http://127.0.0.1/WebRTCAppEE/streams/stream1.m3u8" | |
- name: Uninstall Helm release | |
if: ${{ always() }} | |
run: helm uninstall antmedia -n antmedia | |
- name: Stop Minikube | |
if: ${{ always() }} | |
run: minikube stop | |
- name: Stop docker | |
if: ${{ always() }} | |
run: sudo systemctl stop docker |