Deploy to GCP VM #1
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 to GCP VM | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "0 0 */2 * *" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Authenticate with Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Set up gcloud | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ secrets.GCP_PROJECT }} | |
| - name: Start VM (if stopped) | |
| run: | | |
| gcloud compute instances start ${{ secrets.GCP_VM_NAME }} \ | |
| --zone=${{ secrets.GCP_VM_ZONE }} | |
| - name: Run commands on VM | |
| run: | | |
| gcloud compute ssh ${{ secrets.GCP_VM_NAME }} \ | |
| --zone=${{ secrets.GCP_VM_ZONE }} \ | |
| --command " | |
| sudo rm -r exness && | |
| git clone https://github.com/${{ github.repository }} && | |
| cd exness && | |
| docker compose down -v || true && | |
| docker stop \$(docker ps -aq) || true && | |
| docker rm \$(docker ps -aq) || true && | |
| docker volume prune -f || true && | |
| docker network prune -f || true && | |
| docker compose build --no-cache && | |
| docker compose up -d | |
| " |