@@ -151,31 +151,39 @@ runs:
151151 run : |
152152 # Import GPG key
153153 echo "$GPG_PRIVATE_KEY" | gpg --batch --import
154-
155- # Get the GPG key ID
154+
155+ # Get key ID
156156 KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F : ' /^sec/{print $5}' | head -n1)
157-
158- # Trust the key (avoid interactive trust prompts)
159- echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key "$KEY_ID" trust
160-
161- # Configure Git to use this key
157+
158+ # Trust the key
159+ echo -e "5\ny\n" | gpg --batch --yes --command-fd 0 --edit-key "$KEY_ID" trust
160+
161+ # Configure GPG for non-interactive use
162+ mkdir -p ~/.gnupg
163+ echo "use-agent" >> ~/.gnupg/gpg.conf
164+ echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
165+ echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
166+ echo RELOADAGENT | gpg-connect-agent
167+ export GPG_TTY=$(tty)
168+
169+ # Configure Git
162170 git config --global user.name "${{ inputs.commit-author-name }}"
163171 git config --global user.email "${{ inputs.commit-author-email }}"
164172 git config --global commit.gpgsign true
165173 git config --global user.signingkey "$KEY_ID"
166174 git config --global gpg.program gpg
167-
168- # Prevent pinentry prompt (for passphrase-protected keys)
169- echo "allow-loopback-pinentry" >> ~/.gnupg/gpg.conf
170- echo "use-agent" >> ~/.gnupg/gpg.conf
171- echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
172- echo RELOADAGENT | gpg-connect-agent
175+
176+ # Set passphrase environment variable for Git GPG signing
177+ export GIT_COMMITTER_NAME="${{ inputs.commit-author-name }}"
178+ export GIT_COMMITTER_EMAIL="${{ inputs.commit-author-email }}"
173179 export GPG_TTY=$(tty)
174-
175- # Make the commit
176- git add repo-properties.yaml
180+
181+ # Create the commit (sign with loopback)
177182 echo "$GPG_PASSPHRASE" | \
178- gpg --batch --yes --passphrase-fd 0 \
179- git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit"
180-
183+ gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \
184+ --local-user "$KEY_ID" \
185+ --output /dev/null --sign - 2>/dev/null
186+
187+ git add repo-properties.yaml
188+ git commit -S -m "chore : commit repo custom properties to properties file" || echo "Nothing to commit"
181189 git push
0 commit comments