Skip to content

Commit 28afb1d

Browse files
author
Marvin Zhang
committedJan 3, 2025·
chore: Improve GPG key handling and configuration in GitHub Actions workflow
- Enhanced the GPG key import process by creating a dedicated directory and writing the key to a file before importing. - Added steps to ensure proper GPG directory permissions and configuration, including loopback pinentry settings. - Cleaned up temporary files after key import to maintain security.
1 parent 219ac11 commit 28afb1d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎.github/workflows/publish.yml

+20-1
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,34 @@ jobs:
7474
7575
- name: Import GPG key
7676
run: |
77-
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -d | gpg --batch --import
77+
# Create GPG directory
78+
mkdir -p ~/.gnupg/
79+
chmod 700 ~/.gnupg/
80+
81+
# Write key to file first
82+
echo "${{ secrets.GPG_PRIVATE_KEY }}" > ~/private-key.asc
83+
gpg --batch --import ~/private-key.asc
84+
rm ~/private-key.asc # Clean up
85+
86+
# Verify the key was imported
7887
gpg --list-secret-keys --keyid-format LONG
7988
env:
8089
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
8190

8291
- name: Set up GPG
8392
run: |
93+
# Ensure directory exists
94+
mkdir -p ~/.gnupg/
95+
96+
# Configure GPG
8497
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
8598
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
99+
100+
# Set permissions
101+
chmod 700 ~/.gnupg
102+
chmod 600 ~/.gnupg/*
103+
104+
# Restart agent
86105
gpgconf --kill gpg-agent
87106
gpg-agent --daemon
88107

0 commit comments

Comments
 (0)
Please sign in to comment.