Skip to content

Override Code Sample Metadata #61

Override Code Sample Metadata

Override Code Sample Metadata #61

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 }}