Make release metadata defaults production-safe with local saved defaults #10
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: Staging Validation | ||
| on: | ||
| workflow_run: | ||
| workflows: ["CI/CD Pipeline"] | ||
| branches: ["develop"] | ||
| types: [completed] | ||
| jobs: | ||
| staging-deploy: | ||
| name: Deploy to Staging | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: docker.io | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Build and push staging image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| tags: | | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/spectracleanse-api:staging-${{ github.event.workflow_run.head_commit.sha }} | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/spectracleanse-api:staging-latest | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| - name: Trigger staging deployment | ||
| if: ${{ secrets.STAGING_DEPLOY_HOOK != '' }} | ||
| run: | | ||
| curl -sf -X POST "${{ secrets.STAGING_DEPLOY_HOOK }}" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "image":"${{ secrets.DOCKERHUB_USERNAME }}/spectracleanse-api:staging-${{ github.event.workflow_run.head_commit.sha }}", | ||
| "environment":"staging" | ||
| }' | ||
| - name: Run smoke tests on staging | ||
| run: | | ||
| echo "Waiting for staging deployment..." | ||
| sleep 10 | ||
| if [ ! -z "${{ secrets.STAGING_URL }}" ]; then | ||
| for i in $(seq 1 10); do | ||
| if curl -sf "${{ secrets.STAGING_URL }}/api/health"; then | ||
| echo "Staging health check passed" | ||
| exit 0 | ||
| fi | ||
| sleep 5 | ||
| done | ||
| echo "Staging failed to respond" | ||
| exit 1 | ||
| fi | ||