feat: add the report summaries guide #22
Workflow file for this run
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: Build and Deploy Website | |
| on: | |
| push: # No branches filter, so runs on all branches | |
| pull_request: | |
| types: [ closed ] # Trigger on PR close | |
| branches: [ master ] # Only for PRs targeting master branch | |
| jobs: | |
| test-api: | |
| # This job runs on any branch push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Test API endpoint | |
| id: test_api | |
| uses: fjogeleit/http-request-action@v1 | |
| with: | |
| url: '${{ secrets.API_BASE_URL }}/' | |
| method: 'GET' | |
| customHeaders: '{"Authorization": "Bearer ${{ secrets.API_TOKEN }}"}' | |
| - name: Check API response | |
| run: | | |
| echo "API Response Status: ${{ steps.test_api.outputs.status }}" | |
| echo "API Response Body: ${{ steps.test_api.outputs.response }}" | |
| - name: Failed API response (not status code 200) | |
| if: ${{ steps.test_api.outputs.status != '200' }} | |
| run: | | |
| echo "Error: API returned status code ${{ steps.test_api.outputs.status }}, expected 200" | |
| exit 1 | |
| build-and-deploy: | |
| # Only run this job when a PR is merged to main (not on direct pushes or when PR is closed without merging) | |
| if: github.event_name == 'pull_request' && github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Build site | |
| id: build | |
| uses: fjogeleit/http-request-action@v1 | |
| with: | |
| url: '${{ secrets.API_BASE_URL }}/sites/${{ vars.SITE }}/build' | |
| method: 'POST' | |
| customHeaders: '{"Authorization": "Bearer ${{ secrets.API_TOKEN }}"}' | |
| - name: Check build status | |
| if: ${{ fromJson(steps.build.outputs.response).status != 0 }} | |
| run: | | |
| echo "Build failed with status ${{ fromJson(steps.build.outputs.response).status }}" | |
| echo "Output: ${{ fromJson(steps.build.outputs.response).output }}" | |
| exit 1 | |
| - name: Deploy site if build succeeded | |
| id: deploy | |
| if: ${{ fromJson(steps.build.outputs.response).status == 0 }} | |
| uses: fjogeleit/http-request-action@v1 | |
| with: | |
| url: '${{ secrets.API_BASE_URL }}/sites/${{ vars.SITE }}/deploy' | |
| method: 'POST' | |
| customHeaders: '{"Authorization": "Bearer ${{ secrets.API_TOKEN }}"}' | |
| - name: Check deploy status | |
| if: ${{ fromJson(steps.deploy.outputs.response).status != 0 }} | |
| run: | | |
| echo "Deploy failed with status ${{ fromJson(steps.deploy.outputs.response).status }}" | |
| echo "Output: ${{ fromJson(steps.deploy.outputs.response).output }}" | |
| exit 1 | |
| - name: Deployment summary | |
| if: ${{ fromJson(steps.deploy.outputs.response).status == 0 }} | |
| run: | | |
| echo "✅ Build and deployment completed successfully!" | |
| echo "Build output: ${{ fromJson(steps.build.outputs.response).output }}" | |
| echo "Deploy output: ${{ fromJson(steps.deploy.outputs.response).output }}" | |