chore: tweak update-cli workflow a bit to remove the deploy key

nlf committed May 2, 2022 at 13:52 UTC d3f0599ac820d385f1a8114235713a86d1190446
1 file changed +24 -28
.github/workflows/update-cli.yml
+24 -28
@@ -9,23 +9,17 @@ jobs:
9 build:
10 runs-on: ubuntu-latest
11 steps:
12 - # Check out the content (source branch). Use a deploy key so that
13 - # when we push changes, it will trigger the documentation update
14 - # workflow run that runs on: push. (Using the GitHub token would
15 - # not run the workflow to prevent infinite recursion.)
12 - name: Check out source
13 uses: actions/checkout@v3
14 + - name: Check out documentation branch
15 + uses: actions/checkout@v3
16 with:
19 - ssh-key: ${{ secrets.CLI_DEPLOY_KEY }}
20 -
21 - # Make sure that the new content didn't break the build. We don't
22 - # want to promote anything that would breaks.
17 + ref: 'dist'
18 + path: 'public'
19 - name: Use Node.js
20 uses: actions/setup-node@v3
21 with:
22 node-version: 16.x
27 -
28 - # Add the CLI documentation to the content directory.
23 - name: Install npm packages
24 run: npm ci
25 - name: Fetch latest documentation
@@ -34,37 +28,39 @@ jobs:
28 run: rm -rf content/cli
29 - name: Import documentation
30 run: node cli/cli_import.js
37 -
38 - # Check for changes; this avoids publishing a new change to the
39 - # dist branch when we made a change to (for example) a unit test.
40 - # If there were changes made in the publish step above, then this
41 - # will set the variable `has_changes` to `1` for subsequent steps.
31 - name: Check for changes
32 id: status
33 run: |
34 if [ -n "$(git status --porcelain)" ]; then
35 echo "::set-output name=has_changes::1"
36 fi
48 -
49 - # Commit the changes to the dist branch and push the changes up to
50 - # GitHub. (Replace the name and email address with your own.)
51 - # This step only runs if the previous step set `has_changes` to `1`.
52 - - name: Check in documentation
37 + - name: Check in source updates
38 + if: steps.status.outputs.has_changes == '1'
39 run: |
40 git add --verbose .
41 git config user.name 'CI User'
42 git config user.email 'noreply@npmjs.com'
43 git commit -m 'CLI documentation update from CI'
58 - if: steps.status.outputs.has_changes == '1'
59 -
60 - # Before we publish the changes, ensure the site builds so that we
61 - # don't break the main branch.
44 - name: Build documentation
45 run: npm run build
46 env:
47 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 -
67 - # Publish the documentation updates.
68 - - name: Publish documentation
69 - run: git push origin main
48 + - name: Push source changes
49 if: steps.status.outputs.has_changes == '1'
50 + run: git push origin main
51 + - name: Check for changes to docs
52 + id: docs-status
53 + working-directory: public
54 + run: |
55 + if [ -n "$(git status --porcelain)" ]; then
56 + echo "::set-output name=has_changes::1"
57 + fi
58 + - name: Publish documentation
59 + if: steps.docs-status.outputs.has_changes == '1'
60 + working-directory: public
61 + run: |
62 + git add --verbose .
63 + git config user.name 'CI User'
64 + git config user.email 'noreply@npmjs.com'
65 + git commit -m 'CLI documentation update from CI'
66 + git push origin dist