File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ name: Import API spec
22
33on :
44 workflow_dispatch :
5- inputs :
6- target_branch :
7- description : ' Branch to update'
8- required : true
95
106jobs :
117 create-files :
@@ -27,20 +23,29 @@ jobs:
2723 needs : create-files
2824 runs-on : ubuntu-latest
2925 steps :
30- - name : Checkout target branch
26+ - name : Verify branch context
27+ run : |
28+ echo "Triggered from ref: ${{ github.ref }}"
29+ echo "Branch name: ${{ github.ref_name }}"
30+ if [[ "${{ github.ref_type }}" != "branch" ]]; then
31+ echo "❌ This workflow must be triggered on a branch."
32+ exit 1
33+ fi
34+
35+ - name : Checkout current branch
3136 uses : actions/checkout@v4
3237 with :
33- ref : ${{ github.event.inputs.target_branch }}
38+ ref : ${{ github.ref_name }}
3439
3540 - name : Download artifact
3641 uses : actions/download-artifact@v4
3742 with :
3843 name : output-file
3944
40- - name : Commit changes
45+ - name : Commit and push changes
4146 run : |
4247 git config user.name "github-actions"
4348 git config user.email "github-actions@github.com"
4449 git add output.txt
45- git commit -m "Update branch with generated file" || echo "No changes"
46- git push origin HEAD:${{ github.event.inputs.target_branch }}
50+ git commit -m "Update current branch with generated file" || echo "No changes"
51+ git push origin HEAD:${{ github.ref_name }}
You can’t perform that action at this time.
0 commit comments