.github/workflows/run.yaml #11
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
on: [workflow_dispatch] | |
jobs: | |
run-server: | |
name: run mc serv and open ngrok tunnel | |
runs-on: ubuntu-latest | |
steps: | |
- name: start mc server container | |
run: | | |
docker run -id --name mc --rm \ | |
-p 25565:25565 \ | |
-e START_COMMAND="${{ vars.START_COMMAND }}" \ | |
-e S3_BUCKET_NAME=${{ vars.S3_BUCKET_NAME }} \ | |
-e S3_REGION=${{ vars.S3_REGION }} \ | |
-e BACKUP_FREQUENCY=${{ vars.BACKUP_FREQUENCY }} \ | |
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ | |
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ | |
${{ github.event.act && 'localhost:8080' || 'ghcr.io' }}/${{ vars.IMAGE_REPO }}:latest | |
- name: install ngrok and screen | |
run: | | |
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-${{ vars.ARCHITECTURE || 'amd64' }}.tgz | |
tar -xvf ngrok-v3-stable-linux-${{ vars.ARCHITECTURE || 'amd64' }}.tgz | |
sudo apt-get update | |
sudo apt-get install -y screen | |
- name: open ngrok tunnel in screen (SERVER IP HERE) | |
run: | | |
screen -d -m ./ngrok tcp 25565 --authtoken ${{ secrets.NGROK_AUTHTOKEN }} --log stdout | |
sleep 5 | |
curl -s http://127.0.0.1:4040/api/tunnels | jq -r '.tunnels | .[0] | .public_url | .[6:]' | |
- name: wait until server finishes starting | |
run: timeout 5m grep -m 1 "Done" <(docker logs -f mc) | |
- name: wait for server to be stopped | |
run: docker wait mc | |
- if: ${{ cancelled() }} | |
run: echo "/stop" | docker attach mc |