Skip to content

Update 00-firstworkflow.yaml #8

Update 00-firstworkflow.yaml

Update 00-firstworkflow.yaml #8

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: "${{ 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)"