| 1 | name: Environments |
| 2 | on: |
| 3 | push: |
| 4 | branches: [main] |
| 5 | jobs: |
| 6 | staging: |
| 7 | runs-on: ubuntu-latest |
| 8 | environment: |
| 9 | name: staging |
| 10 | url: https://staging.example.com |
| 11 | steps: |
| 12 | - run: ./deploy.sh staging |
| 13 | plan: |
| 14 | runs-on: ubuntu-latest |
| 15 | environment: |
| 16 | name: production |
| 17 | deployment: false |
| 18 | steps: |
| 19 | - run: ./plan.sh |
| 20 | production: |
| 21 | needs: [staging, plan] |
| 22 | runs-on: ubuntu-latest |
| 23 | environment: |
| 24 | name: production |
| 25 | url: ${{ steps.deploy.outputs.url }} |
| 26 | steps: |
| 27 | - id: deploy |
| 28 | run: echo "url=https://example.com" >> "$GITHUB_OUTPUT" |