update_spec #17
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 Production | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| DO_API_TOKEN: ${{ secrets.DO_API_TOKEN }} | |
| APP_NAME: task-manager-production | |
| jobs: | |
| deploy-production: | |
| name: Deploy to Production Environment | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Install doctl | |
| uses: digitalocean/action-doctl@v2 | |
| with: | |
| token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
| - name: Generate Production App Spec | |
| run: | | |
| mkdir -p .do/generated | |
| cp .do/deploy.template.yaml .do/generated/production-spec.yaml | |
| - name: Deploy to Production | |
| run: | | |
| # Check if app exists | |
| if doctl apps list --format Name --no-header | grep -q "^${APP_NAME}$"; then | |
| APP_ID=$(doctl apps list --format ID,Name --no-header | grep "${APP_NAME}" | cut -d' ' -f1) | |
| doctl apps update ${APP_ID} --spec .do/generated/production-spec.yaml | |
| else | |
| doctl apps create --spec .do/generated/production-spec.yaml | |
| fi |