Skip to content

Commit 0a0eaf2

Browse files
committed
feat: add check-api-key in translate-docs workflow
1 parent 7584af5 commit 0a0eaf2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/translate-docs.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,31 @@ permissions:
2828
pull-requests: write
2929

3030
jobs:
31-
translate:
31+
check-api-key:
3232
runs-on: ubuntu-latest
3333
# Run when manually triggered OR scheduled OR when the commit message contains "Merge pull request"
3434
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || contains(github.event.head_commit.message, 'Merge pull request') }}
35+
outputs:
36+
api_key_exists: ${{ steps.check-api-key.outputs.api_key_exists }}
37+
steps:
38+
# Check if API key is available
39+
- name: Check API key
40+
id: check-api-key
41+
env:
42+
API_KEY: ${{ secrets.OPENAI_API_KEY }}
43+
run: |
44+
if [ -z "$API_KEY" ]; then
45+
echo "OPENAI_API_KEY secret is not set. Skipping translation."
46+
echo "api_key_exists=false" >> $GITHUB_OUTPUT
47+
else
48+
echo "OPENAI_API_KEY secret is available. Proceeding with translation."
49+
echo "api_key_exists=true" >> $GITHUB_OUTPUT
50+
fi
51+
52+
translate:
53+
runs-on: ubuntu-latest
54+
needs: check-api-key
55+
if: ${{ needs.check-api-key.outputs.api_key_exists == 'true' }}
3556
steps:
3657
# Checkout the repository first to access local actions
3758
- name: Checkout code

0 commit comments

Comments
 (0)