Skip to content

Commit 570947b

Browse files
committed
Fix docs deployment workflow to make deploy key condition work.
1 parent eb23d12 commit 570947b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

.github/workflows/docs.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main]
66
paths:
77
- docs/**
8+
- '**/*.yml'
89
push:
910
branches: [main]
1011
paths:
@@ -37,10 +38,26 @@ jobs:
3738
- name: Test build website
3839
run: yarn build
3940

41+
deploy-precheck:
42+
runs-on: ubuntu-latest
43+
if: ${{ github.event_name != 'pull_request' }}
44+
outputs:
45+
gh-deploy-key: ${{ steps.gh-deploy-key.outputs.defined }}
46+
steps:
47+
- id: gh-deploy-key
48+
env:
49+
GH_PAGES_DEPLOY: ${{ secrets.GH_PAGES_DEPLOY }}
50+
if: "${{ env.GH_PAGES_DEPLOY != '' }}"
51+
run: echo "::set-output name=defined::true"
52+
4053
deploy:
41-
if: ${{ github.event_name != 'pull_request' && github.secrets.GH_PAGES_DEPLOY != '' }}
54+
needs: [deploy-precheck]
55+
if: ${{ needs.deploy-precheck.outputs.gh-deploy-key == 'true' }}
4256
runs-on: ubuntu-latest
4357
steps:
58+
- name: Check secret set
59+
run: |
60+
echo "GH_PAGES_DEPLOY: ${{ secrets.GH_PAGES_DEPLOY }}"
4461
- uses: actions/checkout@v4
4562
with:
4663
fetch-depth: 0
@@ -56,13 +73,13 @@ jobs:
5673
cache: yarn
5774
- uses: webfactory/ssh-agent@v0.5.0
5875
with:
59-
ssh-private-key: ${{ github.secrets.GH_PAGES_DEPLOY }}
76+
ssh-private-key: ${{ env.GH_PAGES_DEPLOY }}
6077
- name: Deploy to GitHub Pages
6178
env:
6279
USE_SSH: true
6380
run: |
64-
export COCOINDEX_DOCS_POSTHOG_API_KEY=${{ github.secrets.COCOINDEX_DOCS_POSTHOG_API_KEY }}
65-
export COCOINDEX_DOCS_MIXPANEL_API_KEY=${{ github.secrets.COCOINDEX_DOCS_MIXPANEL_API_KEY }}
81+
export COCOINDEX_DOCS_POSTHOG_API_KEY=${{ secrets.COCOINDEX_DOCS_POSTHOG_API_KEY }}
82+
export COCOINDEX_DOCS_MIXPANEL_API_KEY=${{ secrets.COCOINDEX_DOCS_MIXPANEL_API_KEY }}
6683
git config --global user.email "cocoindex.io@gmail.com"
6784
git config --global user.name "CocoIndex"
6885
yarn install --frozen-lockfile

0 commit comments

Comments
 (0)