|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy-staging: |
| 12 | + name: Deploy to Staging |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: github.ref == 'refs/heads/main' |
| 15 | + environment: |
| 16 | + name: staging |
| 17 | + url: https://staging.example.com |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Deploy to staging server |
| 24 | + run: | |
| 25 | + echo "Deploying to staging environment" |
| 26 | + # Add your deployment commands here |
| 27 | + # Example: ssh user@staging-server "cd /app && git pull && docker-compose up -d" |
| 28 | + |
| 29 | + # Uncomment and configure for actual deployment |
| 30 | + # - name: SSH Deploy |
| 31 | + # uses: appleboy/ssh-action@master |
| 32 | + # with: |
| 33 | + # host: ${{ secrets.STAGING_HOST }} |
| 34 | + # username: ${{ secrets.STAGING_USER }} |
| 35 | + # key: ${{ secrets.STAGING_SSH_KEY }} |
| 36 | + # script: | |
| 37 | + # cd /path/to/app |
| 38 | + # git pull origin main |
| 39 | + # docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d |
| 40 | + |
| 41 | + deploy-production: |
| 42 | + name: Deploy to Production |
| 43 | + runs-on: ubuntu-latest |
| 44 | + if: startsWith(github.ref, 'refs/tags/v') |
| 45 | + environment: |
| 46 | + name: production |
| 47 | + url: https://example.com |
| 48 | + needs: [] |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Deploy to production server |
| 55 | + run: | |
| 56 | + echo "Deploying version ${{ github.ref_name }} to production" |
| 57 | + # Add your deployment commands here |
| 58 | + |
| 59 | + # Uncomment and configure for actual deployment |
| 60 | + # - name: SSH Deploy |
| 61 | + # uses: appleboy/ssh-action@master |
| 62 | + # with: |
| 63 | + # host: ${{ secrets.PRODUCTION_HOST }} |
| 64 | + # username: ${{ secrets.PRODUCTION_USER }} |
| 65 | + # key: ${{ secrets.PRODUCTION_SSH_KEY }} |
| 66 | + # script: | |
| 67 | + # cd /path/to/app |
| 68 | + # git fetch --tags |
| 69 | + # git checkout ${{ github.ref_name }} |
| 70 | + # docker-compose -f docker-compose.yml -f docker-compose.prod.yml pull |
| 71 | + # docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d |
| 72 | + |
| 73 | + - name: Create Release |
| 74 | + uses: softprops/action-gh-release@v1 |
| 75 | + if: startsWith(github.ref, 'refs/tags/v') |
| 76 | + with: |
| 77 | + generate_release_notes: true |
| 78 | + draft: false |
| 79 | + prerelease: false |
0 commit comments