Skip to content

Commit d77a55e

Browse files
authored
Fix docs deployment workflow to make deploy key condition work. (#81)
1 parent eb23d12 commit d77a55e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/workflows/docs.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,26 @@ jobs:
3737
- name: Test build website
3838
run: yarn build
3939

40+
deploy-precheck:
41+
runs-on: ubuntu-latest
42+
if: ${{ github.event_name != 'pull_request' }}
43+
outputs:
44+
gh-deploy-key: ${{ steps.gh-deploy-key.outputs.defined }}
45+
steps:
46+
- id: gh-deploy-key
47+
env:
48+
GH_PAGES_DEPLOY: ${{ secrets.GH_PAGES_DEPLOY }}
49+
if: "${{ env.GH_PAGES_DEPLOY != '' }}"
50+
run: echo "::set-output name=defined::true"
51+
4052
deploy:
41-
if: ${{ github.event_name != 'pull_request' && github.secrets.GH_PAGES_DEPLOY != '' }}
53+
needs: [deploy-precheck]
54+
if: ${{ needs.deploy-precheck.outputs.gh-deploy-key == 'true' }}
4255
runs-on: ubuntu-latest
4356
steps:
57+
- name: Check secret set
58+
run: |
59+
echo "GH_PAGES_DEPLOY: ${{ secrets.GH_PAGES_DEPLOY }}"
4460
- uses: actions/checkout@v4
4561
with:
4662
fetch-depth: 0
@@ -56,13 +72,13 @@ jobs:
5672
cache: yarn
5773
- uses: webfactory/[email protected]
5874
with:
59-
ssh-private-key: ${{ github.secrets.GH_PAGES_DEPLOY }}
75+
ssh-private-key: ${{ env.GH_PAGES_DEPLOY }}
6076
- name: Deploy to GitHub Pages
6177
env:
6278
USE_SSH: true
6379
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 }}
80+
export COCOINDEX_DOCS_POSTHOG_API_KEY=${{ secrets.COCOINDEX_DOCS_POSTHOG_API_KEY }}
81+
export COCOINDEX_DOCS_MIXPANEL_API_KEY=${{ secrets.COCOINDEX_DOCS_MIXPANEL_API_KEY }}
6682
git config --global user.email "[email protected]"
6783
git config --global user.name "CocoIndex"
6884
yarn install --frozen-lockfile

0 commit comments

Comments
 (0)