Skip to content

Commit a20713c

Browse files
authored
fix: mask decoded PGP key in CI logs (#20)
## Summary - Decode base64 PGP key and mask with `::add-mask::` before passing to Gradle - Key stays in process memory, never written to `$GITHUB_ENV` - Empty lines filtered to avoid `add-mask` warnings ## Test plan - [x] Masking verified on [test repo](https://github.com/endrju19/test-pgp-masking) — decoded key shows as `***` in logs - [ ] CI passes
1 parent 1b72937 commit a20713c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,16 @@ jobs:
113113
- name: Setup Gradle
114114
uses: gradle/actions/setup-gradle@39e147cb9de83bb9910b8ef8bd7fff0ee20fcd6f # v6.0.1
115115

116-
- name: Decode PGP key
116+
- name: Publish to Maven Central
117117
run: |
118-
echo "$PGP_SECRET_BASE64" | base64 -d > /tmp/secring.asc
119-
echo "ORG_GRADLE_PROJECT_signingInMemoryKey<<EOF" >> $GITHUB_ENV
120-
cat /tmp/secring.asc >> $GITHUB_ENV
121-
echo "EOF" >> $GITHUB_ENV
122-
rm /tmp/secring.asc
118+
DECODED_KEY=$(echo "$PGP_SECRET_BASE64" | base64 -d)
119+
while IFS= read -r line; do
120+
[ -n "$line" ] && echo "::add-mask::$line"
121+
done <<< "$DECODED_KEY"
122+
export ORG_GRADLE_PROJECT_signingInMemoryKey="$DECODED_KEY"
123+
./gradlew publishAndReleaseToMavenCentral
123124
env:
124125
PGP_SECRET_BASE64: ${{ secrets.PGP_SECRET }}
125-
126-
- name: Publish to Maven Central
127-
run: ./gradlew publishAndReleaseToMavenCentral
128-
env:
129126
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
130127
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
131128
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_PASSPHRASE }}

0 commit comments

Comments
 (0)