Fix: docker build corrections #32
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 development | |
| on: | |
| 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" | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy-dev: | |
| runs-on: self-hosted | |
| env: | |
| REPO_NAME: ${{ github.event.repository.name }} | |
| COMPOSE_FILE: >- | |
| ${{ github.event.inputs.config || | |
| (github.ref == 'refs/heads/dev' && 'docker-compose.dev.yml') || | |
| (github.ref == 'refs/heads/stage' && 'docker-compose.stag.yml') || | |
| (github.ref == 'refs/heads/main' && 'docker-compose.yml') | |
| }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Check Docker installation | |
| run: | | |
| if ! command -v docker &> /dev/null; then | |
| echo "Docker is not installed" | |
| exit 1 | |
| fi | |
| if ! docker info &> /dev/null; then | |
| echo "Docker daemon is not running" | |
| exit 1 | |
| fi | |
| - name: Set up environment variables | |
| uses: falti/dotenv-action@v1.1.4 | |
| with: | |
| export-variables: true | |
| keys-case: bypass | |
| - name: Check environment variables (should not really be here as you might expose secrets ) | |
| run: env | |
| - name: Find config file and build | |
| run: | | |
| cd $GITHUB_WORKSPACE | |
| docker compose -f $COMPOSE_FILE config || exit 1 | |
| - name: build and run docker file | |
| run: | | |
| docker compose -f $COMPOSE_FILE up --force-recreate --build -d || exit 1 | |
| - name: Verify running Docker containers | |
| run: docker ps |