Override Code Sample Metadata #61
This file contains 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: Override Code Sample Metadata | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
branches: | |
- main | |
workflow_run: | |
workflows: ["Generate"] | |
types: | |
- completed | |
jobs: | |
replace_text: | |
if: > | |
${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if PR exists | |
id: check_pr | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_run" && -z "${{ github.event.workflow_run.pull_requests }}" ]]; then | |
echo "No PR was created by the Generate workflow. Skipping further steps." | |
echo "pr_exists=false" >> $GITHUB_ENV | |
else | |
echo "pr_exists=true" >> $GITHUB_ENV | |
fi | |
- name: Debug event information | |
run: | | |
echo "Event Name: ${{ github.event_name }}" | |
echo "Workflow Run Head Branch: ${{ github.event.workflow_run.head_branch }}" | |
echo "Pull Request Head Ref: ${{ github.head_ref }}" | |
- name: Checkout repository | |
if: env.pr_exists == 'true' | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.event_name == 'pull_request' && github.head_ref }} |