Skip to content

Commit 9cc7eeb

Browse files
miaulalalaclaude
andcommitted
debug: add logging to docs PR step and fix skip logic
- Split into check step + run step to avoid secrets-in-if issue - Add detailed logging with ::group:: sections for each phase - Re-add push trigger for testing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 81b165e commit 9cc7eeb

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

.github/workflows/screenshots.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
name: Documentation Screenshots
55

66
on:
7+
push: # TODO: remove before merging — temporary trigger for CI testing
78
workflow_dispatch:
89
inputs:
910
server-branch:
@@ -94,35 +95,75 @@ jobs:
9495
# Opens a PR against nextcloud/documentation with updated screenshots.
9596
# Uses the org-wide COMMAND_BOT_PAT secret.
9697
# The step is skipped gracefully if the secret is not configured.
98+
- name: Check if docs PR should be created
99+
id: docs-pr-check
100+
env:
101+
COMMAND_BOT_PAT: ${{ secrets.COMMAND_BOT_PAT }}
102+
OPEN_DOCS_PR: ${{ inputs.open-docs-pr }}
103+
run: |
104+
echo "::group::Debug info"
105+
echo "inputs.open-docs-pr = '${OPEN_DOCS_PR}'"
106+
echo "COMMAND_BOT_PAT is set = $([ -n "$COMMAND_BOT_PAT" ] && echo 'yes' || echo 'no')"
107+
echo "event_name = ${{ github.event_name }}"
108+
echo "::endgroup::"
109+
110+
if [ -z "$COMMAND_BOT_PAT" ]; then
111+
echo "COMMAND_BOT_PAT is not set, skipping docs PR."
112+
echo "should_run=false" >> "$GITHUB_OUTPUT"
113+
elif [ "$OPEN_DOCS_PR" = "false" ]; then
114+
echo "open-docs-pr is false, skipping docs PR."
115+
echo "should_run=false" >> "$GITHUB_OUTPUT"
116+
else
117+
echo "Will attempt to create docs PR."
118+
echo "should_run=true" >> "$GITHUB_OUTPUT"
119+
fi
120+
97121
- name: Open PR against nextcloud/documentation
98-
if: inputs.open-docs-pr != false && env.COMMAND_BOT_PAT != ''
122+
if: steps.docs-pr-check.outputs.should_run == 'true'
99123
env:
100124
COMMAND_BOT_PAT: ${{ secrets.COMMAND_BOT_PAT }}
101125
run: |
126+
set -e
102127
DOCS_BRANCH="chore/activity-screenshots-$(date +%Y%m%d-%H%M%S)"
103128
SCREENSHOT_DIR="cypress/snapshots/actual/screenshots.cy.ts"
104129
105-
# Clone the documentation repo using the PAT
130+
echo "::group::Clone documentation repo"
106131
git clone --depth 1 "https://x-access-token:${COMMAND_BOT_PAT}@github.com/nextcloud/documentation.git" /tmp/documentation
107132
cd /tmp/documentation
133+
echo "Clone successful"
134+
echo "::endgroup::"
108135
109136
git config user.name "nextcloud-command"
110137
git config user.email "nextcloud-command@users.noreply.github.com"
111138
git checkout -b "$DOCS_BRANCH"
112139
140+
echo "::group::Copy screenshots"
113141
# Copy user screenshots
114142
if [ -d "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/user" ]; then
143+
echo "User screenshot files:"
144+
ls -la "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/user/"
115145
cp "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/user/"*.png user_manual/images/
116-
echo "Copied user screenshots"
146+
echo "Copied user screenshots to user_manual/images/"
147+
else
148+
echo "WARNING: No user screenshot directory found at $GITHUB_WORKSPACE/$SCREENSHOT_DIR/user"
117149
fi
118150
119151
# Copy admin screenshots
120152
if [ -d "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/admin" ]; then
153+
echo "Admin screenshot files:"
154+
ls -la "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/admin/"
121155
cp "$GITHUB_WORKSPACE/$SCREENSHOT_DIR/admin/"*.png admin_manual/images/
122-
echo "Copied admin screenshots"
156+
echo "Copied admin screenshots to admin_manual/images/"
157+
else
158+
echo "WARNING: No admin screenshot directory found at $GITHUB_WORKSPACE/$SCREENSHOT_DIR/admin"
123159
fi
160+
echo "::endgroup::"
124161
125162
# Check if there are changes to commit
163+
echo "::group::Git status"
164+
git status
165+
echo "::endgroup::"
166+
126167
if git diff --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then
127168
echo "No screenshot changes detected, skipping PR."
128169
exit 0
@@ -135,10 +176,15 @@ jobs:
135176
PR_TITLE="chore: update activity app screenshots"
136177
fi
137178
179+
echo "::group::Commit and push"
138180
git add user_manual/images/activity-*.png admin_manual/images/activity-*.png
181+
git diff --cached --stat
139182
git commit -m "$PR_TITLE"
140183
git push origin "$DOCS_BRANCH"
184+
echo "Pushed branch $DOCS_BRANCH"
185+
echo "::endgroup::"
141186
187+
echo "::group::Create PR"
142188
# Create the PR
143189
GH_TOKEN="${COMMAND_BOT_PAT}" gh pr create \
144190
--repo nextcloud/documentation \
@@ -160,6 +206,7 @@ jobs:
160206
Generated automatically by the Activity app [screenshot workflow](https://github.com/nextcloud/activity/actions/workflows/screenshots.yml).
161207
EOF
162208
)"
209+
echo "::endgroup::"
163210
164211
echo "PR created successfully"
165212

0 commit comments

Comments
 (0)