deploy #8
This file contains hidden or 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 | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["build-backend", "build-frontend"] | |
| types: | |
| - completed | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "docker-compose.yml" | |
| jobs: | |
| deploy: | |
| name: Deploy to prod | |
| runs-on: self-hosted | |
| environment: prod | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@master | |
| - name: Set up project | |
| run: | | |
| mkdir -p "$DEPLOY_PATH" | |
| mkdir -p "$DEPLOY_PATH/backend" | |
| mkdir -p "$DEPLOY_PATH/frontend" | |
| cp -f ./docker-compose.yml "$DEPLOY_PATH/docker-compose.yml" | |
| APP_VERSION=$(git describe --tags --abbrev=0 || echo "latest") | |
| echo "$BACKEND_ENV_CONTENT" > "$DEPLOY_PATH/backend/.env" | |
| echo "$FRONTEND_ENV_CONTENT" > "$DEPLOY_PATH/frontend/.env" | |
| echo "APP_VERSION=${APP_VERSION}" >> "$DEPLOY_PATH/backend/.env" | |
| echo "APP_VERSION=${APP_VERSION}" >> "$DEPLOY_PATH/frontend/.env" | |
| env: | |
| DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} | |
| BACKEND_ENV_CONTENT: ${{ secrets.BACKEND_ENV_CONTENT }} | |
| FRONTEND_ENV_CONTENT: ${{ secrets.FRONTEND_ENV_CONTENT }} | |
| - name: Pull changes and restart | |
| run: | | |
| cd "${{ secrets.DEPLOY_PATH }}" | |
| docker compose down --remove-orphans | |
| docker compose pull | |
| docker compose up -d |