Updated deploy_test.yml #3
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 | |
| on: | |
| push: | |
| branches: | |
| - dev # Deploy Dev when pushing to `dev` | |
| - staging # Deploy Staging when pushing to `staging` | |
| - main # Deploy Prod when pushing to `main` | |
| 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: | |
| COMPOSE_FILE: ${{ github.ref == 'refs/heads/main' && 'docker-compose.yml' || github.ref == 'refs/heads/staging' && 'docker-compose.stag.yml' || 'docker-compose.dev.yml' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Load environment variables | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Stop existing containers | |
| run: docker compose -f $COMPOSE_FILE down | |
| - name: Build and run updated containers | |
| run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d | |
| - name: Verify running containers | |
| run: docker ps |