deploy-prod #20
Workflow file for this run
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-prod | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| deploy-production: | |
| runs-on: ubuntu-latest | |
| environment: photi-prod | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Create env file | |
| run: | | |
| echo "${{ secrets.ENV_VARS }}" >> ./docker/prod/.env | |
| - name: Create remote directory | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.DEPLOY_KEY }} | |
| script: mkdir -p ~/srv/ubuntu | |
| - name: Copy source via ssh key | |
| uses: burnett01/rsync-deployments@7.0.2 | |
| with: | |
| switches: -avzr --delete | |
| remote_path: ~/srv/ubuntu/ | |
| remote_host: ${{ secrets.DEPLOY_HOST }} | |
| remote_user: ubuntu | |
| remote_key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Execute remote SSH commands using password | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.DEPLOY_KEY }} | |
| script: | | |
| echo "start docker-compose up: ubuntu" | |
| sudo docker-compose -v | |
| sudo docker-compose -f ~/srv/ubuntu/docker/prod/docker-compose.yml pull | |
| sudo docker-compose -f ~/srv/ubuntu/docker/prod/docker-compose.yml --env-file ~/srv/ubuntu/docker/prod/.env up --build -d | |
| echo "prune images" | |
| sudo docker system prune --all -f |