Update deploy_test.yml #2
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: Deploy to TDT4242 server development | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger on push to the main branch | |
| workflow_dispatch: | |
| inputs: | |
| config: | |
| description: "Which compose config file to deploy" | |
| required: true | |
| default: "docker-compose.dev.yml" | |
| type: choice | |
| options: | |
| - "docker-compose.dev.yml" | |
| - "docker-compose.stag.yml" | |
| - "docker-compose.yml" | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| env: | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| 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: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Check status of config file | |
| run: | | |
| env | |
| docker compose version | |
| cd $GITHUB_WORKSPACE | |
| 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 | |
| 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 |