Skip to content

Commit cbd27f2

Browse files
committed
#debug: add push as trigger
1 parent ba79712 commit cbd27f2

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

.github/workflows/test-signed-commit.yaml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
type: string
99
required: true
1010
default: 'test-signed-commit'
11+
push:
12+
branches:
13+
- ROU-12531-fix-3
1114

1215
jobs:
1316
test-signed-commit:
@@ -37,24 +40,43 @@ jobs:
3740
with:
3841
key-name: o11odc-github-gitpersonal-token-prd
3942

40-
- name: 📂 Checkout into dev
43+
# Determine the branch to use:
44+
# - If triggered manually (workflow_dispatch), use the input or default to 'test-signed-commit'
45+
# - If triggered by push, use the branch that was pushed to (github.ref_name)
46+
- name: 🔍 Determine branch name
47+
id: determine-branch
48+
run: |
49+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
50+
BRANCH_NAME="${{ inputs.test-branch }}"
51+
else
52+
BRANCH_NAME="${{ github.ref_name }}"
53+
fi
54+
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
55+
echo "Using branch: $BRANCH_NAME"
56+
57+
# Checkout the target branch. If triggered by push, checkout the pushed branch.
58+
# If triggered manually, checkout dev first, then create/checkout the test branch.
59+
- name: 📂 Checkout branch
4160
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4261
with:
43-
ref: dev
62+
ref: ${{ github.event_name == 'workflow_dispatch' && 'dev' || github.ref_name }}
4463
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
4564

46-
# Create a test branch from dev for testing signed commits.
65+
# Create a test branch from dev for testing signed commits (only when triggered manually).
4766
# If the branch already exists, checkout the existing branch instead of creating a duplicate.
48-
- name: 🔄 Create test branch ${{ inputs.test-branch }}
67+
# When triggered by push, we're already on the correct branch.
68+
- name: 🔄 Create test branch ${{ steps.determine-branch.outputs.branch-name }}
69+
if: github.event_name == 'workflow_dispatch'
4970
run: |
50-
if git ls-remote --exit-code --heads origin ${{ inputs.test-branch }}; then
51-
echo "Branch ${{ inputs.test-branch }} already exists. Checking out..."
52-
git fetch origin ${{ inputs.test-branch }}
53-
git checkout ${{ inputs.test-branch }}
71+
BRANCH_NAME="${{ steps.determine-branch.outputs.branch-name }}"
72+
if git ls-remote --exit-code --heads origin $BRANCH_NAME; then
73+
echo "Branch $BRANCH_NAME already exists. Checking out..."
74+
git fetch origin $BRANCH_NAME
75+
git checkout $BRANCH_NAME
5476
else
55-
echo "Creating new branch ${{ inputs.test-branch }}"
56-
git checkout -b ${{ inputs.test-branch }}
57-
git push -u origin ${{ inputs.test-branch }}
77+
echo "Creating new branch $BRANCH_NAME"
78+
git checkout -b $BRANCH_NAME
79+
git push -u origin $BRANCH_NAME
5880
fi
5981
env:
6082
GITHUB_TOKEN: ${{ steps.get-github-token.outputs.az-keyvault-value }}
@@ -86,7 +108,7 @@ jobs:
86108
#uses: OutSystems/rd.github-reusable-workflows/.github/actions/signed-commit@9d497d1c5bc6e355aa8f4663539e6b75c212f6b4 #v2.0.7
87109
uses: ./.github/actions/signed-commit
88110
with:
89-
commit-branch: ${{ inputs.test-branch }}
111+
commit-branch: ${{ steps.determine-branch.outputs.branch-name }}
90112
commit-message: 'Test: GPG signed commit [skip ci]'
91113
commit-new-files: true
92114
gpg-priv-key: ${{ secrets.GPG_SIGN_KEY }}
@@ -100,7 +122,7 @@ jobs:
100122
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
101123
with:
102124
token: ${{ steps.get-github-token.outputs.az-keyvault-value }}
103-
branch: ${{ inputs.test-branch }}
125+
branch: ${{ steps.determine-branch.outputs.branch-name }}
104126
base: dev
105127
title: 'Test: GPG Signed Commit'
106128
body: |

0 commit comments

Comments
 (0)