@@ -138,9 +138,37 @@ runs:
138138 - name : Commit values to repo-properties.yaml
139139 if : ${{ inputs.dry-run-enabled != 'true' }}
140140 shell : bash
141+ env :
142+ GPG_PRIVATE_KEY : ${{ secrets.GPG_KEY_CONTENTS }}
143+ GPG_PASSPHRASE : ${{ secrets.GPG_KEY_PASSPHRASE }}
141144 run : |
142- git config user.name "${{ inputs.commit-author-name }}"
143- git config user.email "${{ inputs.commit-author-email }}"
145+ # Import GPG key
146+ echo "$GPG_PRIVATE_KEY" | gpg --batch --import
147+
148+ # Get the GPG key ID
149+ KEY_ID=$(gpg --list-secret-keys --with-colons | awk -F: '/^sec/{print $5}' | head -n1)
150+
151+ # Trust the key (avoid interactive trust prompts)
152+ echo -e "5\ny\n" | gpg --command-fd 0 --expert --edit-key "$KEY_ID" trust
153+
154+ # Configure Git to use this key
155+ git config --global user.name "${{ inputs.commit-author-name }}"
156+ git config --global user.email "${{ inputs.commit-author-email }}"
157+ git config --global commit.gpgsign true
158+ git config --global user.signingkey "$KEY_ID"
159+ git config --global gpg.program gpg
160+
161+ # Prevent pinentry prompt (for passphrase-protected keys)
162+ echo "allow-loopback-pinentry" >> ~/.gnupg/gpg.conf
163+ echo "use-agent" >> ~/.gnupg/gpg.conf
164+ echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
165+ echo RELOADAGENT | gpg-connect-agent
166+ export GPG_TTY=$(tty)
167+
168+ # Make the commit
144169 git add repo-properties.yaml
145- git commit -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit"
170+ echo "$GPG_PASSPHRASE" | \
171+ gpg --batch --yes --passphrase-fd 0 \
172+ git commit -S -m "chore: commit repo custom properties to properties file" || echo "Nothing to commit"
173+
146174 git push
0 commit comments