Update 00-firstworkflow.yaml #6
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: 00-first workflow | |
on: | |
push: | |
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 | |
else | |
BRANCH_NAME="${{ github.event.inputs.branch }}" | |
fi | |
else | |
# Extract branch name from github.ref | |
BRANCH_NAME="${{ github.ref }}" | |
# BRANCH_NAME="${BRANCH_NAME##*/}" # This removes everything before the last '/' | |
fi | |
echo "Checkout branch $BRANCH_NAME" | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: "$BRANCH_NAME" |