Skip to content

Update 01-firstworkflow.yaml #11

Update 01-firstworkflow.yaml

Update 01-firstworkflow.yaml #11

name: 01-first workflow
on:
push:
pull_request:
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
type: string
default: 'dev'
jobs:
echo-hello:
runs-on: ubuntu-latest
steps:
- name: Trigger
run: echo "Triggered by ${{github.event_name}} event"
- name: Check Branch Input
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ -z "${{ github.event.inputs.branch }}" ]; then
echo "Branch input is required for manual trigger."
exit 1
fi
fi
- name: Checkout
uses: actions/[email protected]
with:
ref: "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}"
- name: Log Current Branch and Commit
run: |
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Current commit: $(git rev-parse HEAD)"