From ce225a88c817474b04fd4ed4803dd25f34168e13 Mon Sep 17 00:00:00 2001 From: Jonathan Inge Arvesen Folland Date: Thu, 20 Mar 2025 17:54:17 +0100 Subject: [PATCH] Update deploy_test.yml --- .github/workflows/deploy_test.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index a14f485..1788d08 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -1,6 +1,9 @@ name: Deploy to TDT4242 server development on: + push: + branches: + - main # Trigger on push to the main branch workflow_dispatch: inputs: config: @@ -18,11 +21,12 @@ jobs: runs-on: self-hosted env: REPO_NAME: ${{ github.event.repository.name }} - COMPOSE_FILE: ${{ github.event.inputs.config }} - + COMPOSE_FILE: ${{ github.event.inputs.config || 'docker-compose.dev.yml' }} # Default to dev config if not specified + steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Dotenv Action uses: falti/dotenv-action@v1.1.4 with: @@ -34,10 +38,17 @@ jobs: env docker compose version cd $GITHUB_WORKSPACE - docker compose -f $COMPOSE_FILE --verbose config && printf "OK\n" || exit 1 - - - name: Build and run docker image - run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d - + docker compose -f $COMPOSE_FILE --verbose config && printf "OK\n" || exit 1 + + - name: Build and run docker images + run: | + cd $GITHUB_WORKSPACE + docker compose -f $COMPOSE_FILE down # Stop and remove existing containers + docker compose -f $COMPOSE_FILE up --force-recreate --build -d # Rebuild and start containers + - name: Verify that gateway is available - run: docker ps + run: | + docker ps + echo "Waiting for gateway to start..." + sleep 10 # Wait for the gateway to start + curl -I http://localhost:20436 || exit 1 # Verify gateway is accessible