A deploy job creates a unique preview URL per PR. How should you capture and display this URL in GitHub's deployment environment view?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Use a step to capture the dynamic URL, then wire it into 'environment: url: ${{ steps.deploy.outputs.url }}' so GitHub displays it as the live deployment link.
Full explanation below image
Full Explanation
The workflow pattern for dynamic deployment URLs: (1) Run the deploy step with 'id: deploy'; (2) Have the deploy step output the URL via '${{ steps.deploy.outputs.url }}' or by writing to GITHUB_OUTPUT; (3) In the job's 'environment:' block, set 'url: ${{ steps.deploy.outputs.url }}'. This makes the URL appear as the 'View deployment' button in GitHub's Environment view and in the PR deployments section. Pre-setting DEPLOYMENT_URL before the deploy step won't work because the URL isn't known until after deployment. Posting as a PR comment is useful but doesn't populate the official environment view.