A team adds a reusable validation workflow for Copilot-generated pull requests. The workflow should upload logs on failure, avoid publishing secrets, and keep the required check failed when validation fails. Evaluate the following statements. 1. The workflow uploads diagnostics when validation fails. 2. Printing the environment is safe because secrets are masked. 3. The final step helps preserve a failed required check.
name: validate-agent-output
on:
pull_request:
branches:
- main
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
env:
API_TOKEN: ${{ secrets.TEST_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Run validation
id: validation
run: |
mkdir -p diagnostics
npm ci
npm test 2>&1 | tee diagnostics/output.log
- name: Upload diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: validation-diagnostics
path: diagnostics/
- name: Print environment for debugging
if: failure()
run: env | sort
- name: Preserve failure
if: steps.validation.outcome == 'failure'
run: exit 1Choose an answer
Tap an option to check your answer.
Correct answer: 1=Yes 2=No 3=Yes.
Why this is the answer
Statement 1 is correct. The "Upload diagnostics" step uses if: failure() to ensure it only runs if a previous step in the job fails, specifically uploading the diagnostics/ directory containing output.log from the npm test command. Statement 2 is incorrect. While GitHub Actions attempts to mask secrets in logs, printing the entire environment (env | sort) can inadvertently expose sensitive information if a secret is present as an environment variable and not properly masked, or if it's part of a larger string that isn't fully recognized as a secret. It's generally safer to avoid printing the full environment. Statement 3 is correct. The "Preserve failure" step explicitly runs exit 1 if the validation step's outcome was 'failure'. This ensures that even if subsequent steps (like uploading diagnostics or printing the environment) succeed, the overall job will still report a failure, thus keeping the required check failed.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed