Skip to content

Commit 0408827

Browse files
committed
Add pending cloud-compilation/build status and derive committer from GPG uid
Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
1 parent 276b723 commit 0408827

1 file changed

Lines changed: 58 additions & 10 deletions

File tree

.github/workflows/test-cloud-compilation.yml

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,21 @@ jobs:
150150
permissions:
151151
contents: read
152152
pull-requests: write
153+
statuses: write
153154
steps:
155+
- name: Post pending status for cloud-compilation/build
156+
uses: actions/github-script@v7
157+
with:
158+
script: |
159+
await github.rest.repos.createCommitStatus({
160+
owner: context.repo.owner,
161+
repo: context.repo.repo,
162+
sha: '${{ needs.decide.outputs.pr_head_sha }}',
163+
state: 'pending',
164+
context: 'cloud-compilation/build',
165+
description: 'Syncing changes to cloud-compilation...'
166+
});
167+
154168
- name: Checkout flink-sql-runner repo
155169
uses: actions/checkout@v4
156170
with:
@@ -173,22 +187,32 @@ jobs:
173187
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
174188
KEY_ID=$(gpg --list-secret-keys --keyid-format=long --with-colons \
175189
| awk -F: '/^sec/ {print $5; exit}')
176-
if [ -z "$KEY_ID" ]; then
177-
echo "Failed to determine GPG key id"
190+
UID_LINE=$(gpg --list-secret-keys --with-colons \
191+
| awk -F: '/^uid/ {print $10; exit}')
192+
USER_NAME=$(echo "$UID_LINE" | sed -E 's/ *<[^>]+>$//')
193+
USER_EMAIL=$(echo "$UID_LINE" | sed -E 's/.*<([^>]+)>.*/\1/')
194+
if [ -z "$KEY_ID" ] || [ -z "$USER_EMAIL" ]; then
195+
echo "Failed to determine GPG key id / uid (key_id=${KEY_ID}, uid=${UID_LINE})"
178196
exit 1
179197
fi
180198
mkdir -p ~/.gnupg
181199
echo "default-key ${KEY_ID}" >> ~/.gnupg/gpg.conf
182200
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
183-
echo "key_id=${KEY_ID}" >> "$GITHUB_OUTPUT"
201+
{
202+
echo "key_id=${KEY_ID}"
203+
echo "user_name=${USER_NAME}"
204+
echo "user_email=${USER_EMAIL}"
205+
} >> "$GITHUB_OUTPUT"
184206
185207
- name: Configure git
186208
env:
187209
KEY_ID: ${{ steps.gpg.outputs.key_id }}
210+
USER_NAME: ${{ steps.gpg.outputs.user_name }}
211+
USER_EMAIL: ${{ steps.gpg.outputs.user_email }}
188212
run: |
189213
cd compilation
190-
git config user.name "Datasqrl - Automation Bot"
191-
git config user.email "bot@datasqrl.com"
214+
git config user.name "${USER_NAME}"
215+
git config user.email "${USER_EMAIL}"
192216
git config user.signingkey "${KEY_ID}"
193217
git config commit.gpgsign true
194218
@@ -355,6 +379,20 @@ jobs:
355379
echo "Comment already exists, skipping..."
356380
fi
357381
382+
- name: Post failure status for cloud-compilation/build
383+
if: failure()
384+
uses: actions/github-script@v7
385+
with:
386+
script: |
387+
await github.rest.repos.createCommitStatus({
388+
owner: context.repo.owner,
389+
repo: context.repo.repo,
390+
sha: '${{ needs.decide.outputs.pr_head_sha }}',
391+
state: 'failure',
392+
context: 'cloud-compilation/build',
393+
description: 'Sync to cloud-compilation failed'
394+
});
395+
358396
- name: Add rocket reaction
359397
if: success() && github.event_name == 'issue_comment'
360398
env:
@@ -416,22 +454,32 @@ jobs:
416454
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
417455
KEY_ID=$(gpg --list-secret-keys --keyid-format=long --with-colons \
418456
| awk -F: '/^sec/ {print $5; exit}')
419-
if [ -z "$KEY_ID" ]; then
420-
echo "Failed to determine GPG key id"
457+
UID_LINE=$(gpg --list-secret-keys --with-colons \
458+
| awk -F: '/^uid/ {print $10; exit}')
459+
USER_NAME=$(echo "$UID_LINE" | sed -E 's/ *<[^>]+>$//')
460+
USER_EMAIL=$(echo "$UID_LINE" | sed -E 's/.*<([^>]+)>.*/\1/')
461+
if [ -z "$KEY_ID" ] || [ -z "$USER_EMAIL" ]; then
462+
echo "Failed to determine GPG key id / uid (key_id=${KEY_ID}, uid=${UID_LINE})"
421463
exit 1
422464
fi
423465
mkdir -p ~/.gnupg
424466
echo "default-key ${KEY_ID}" >> ~/.gnupg/gpg.conf
425467
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
426-
echo "key_id=${KEY_ID}" >> "$GITHUB_OUTPUT"
468+
{
469+
echo "key_id=${KEY_ID}"
470+
echo "user_name=${USER_NAME}"
471+
echo "user_email=${USER_EMAIL}"
472+
} >> "$GITHUB_OUTPUT"
427473
428474
- name: Configure git
429475
if: steps.branch_exists.outputs.exists == 'true'
430476
env:
431477
KEY_ID: ${{ steps.gpg.outputs.key_id }}
478+
USER_NAME: ${{ steps.gpg.outputs.user_name }}
479+
USER_EMAIL: ${{ steps.gpg.outputs.user_email }}
432480
run: |
433-
git config user.name "Datasqrl - Automation Bot"
434-
git config user.email "bot@datasqrl.com"
481+
git config user.name "${USER_NAME}"
482+
git config user.email "${USER_EMAIL}"
435483
git config user.signingkey "${KEY_ID}"
436484
git config commit.gpgsign true
437485

0 commit comments

Comments
 (0)