Skip to content

Commit f92c0f2

Browse files
authored
Auto codespace feedback round 2 (#54706)
1 parent cd8bf2a commit f92c0f2

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

.github/workflows/codespace-review-check.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ jobs:
3232
LOGIN: docs-bot
3333
REPO: github/docs-internal
3434
run: |
35-
ago=$(date -d '225 minutes ago' -Iseconds)
35+
# If its approaching 4 hours, update the comment
36+
# But don't keep trying to update the comment after 5 hours cause that wastes API calls
37+
from=$(date -d '285 minutes ago' -Iseconds) # 5 * 60 - 15 = 285
38+
until=$(date -d '225 minutes ago' -Iseconds) # 4 * 60 - 15 = 225
3639
echo "- Ago: $ago"
3740
# on mac: date -v-225M -Iseconds
38-
# -v-225M means 225 minutes ago, 4 * 60 - 15 = 225
3941
# -Iseconds means ISO 8601 format, to seconds
4042
branches=$(
4143
gh codespace list \
4244
--repo "$REPO" \
4345
--limit 1000 \
4446
--json name,owner,lastUsedAt,gitStatus \
45-
--jq ".[] | select(.owner == \"$LOGIN\" and .lastUsedAt < \"$ago\") | .gitStatus.ref" \
47+
--jq ".[] | select(.owner == \"$LOGIN\" and .lastUsedAt < \"$until\" and .lastUsedAt > \"$from\") | .gitStatus.ref" \
4648
)
4749
echo "- Branches:"
4850
echo "$(echo "$branches" | sed 's/^/ /')"
@@ -111,14 +113,14 @@ jobs:
111113
112114
### Review this PR in a codespace 📦
113115
114-
Your codespace is no longer active.
116+
The codespace is no longer active.
115117
You’ve reached the 4 hour limit.
116-
In order to reactivate your codespace, please update your pull request by adding the https://github.com/${{ env.REPO }}/labels/extend-codespace label.
117-
If the label is already applied, you can remove and reapply the label to reactivate your codespace.
118+
In order to reactivate the codespace, please update the pull request by adding the https://github.com/${{ env.REPO }}/labels/extend-codespace label.
119+
If the label is already applied, you can remove and reapply the label to reactivate the codespace.
118120
119121
🤖 This comment is [automatically generated][workflow].
120122
121-
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/codespace-review-check.yml
123+
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.workflow_sha }}/.github/workflows/codespace-review-check.yml
122124
123125
- uses: ./.github/actions/slack-alert
124126
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}

.github/workflows/codespace-review-down.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
7878
### Review this PR in a codespace 📦
7979
80-
Your pull request is now merged or closed, so I've removed all automatically created codespaces.
80+
The pull request is now merged or closed, so I've removed all automatically created codespaces.
8181
8282
🤖 This comment is [automatically generated][workflow].
8383
84-
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/codespace-review-down.yml
84+
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.workflow_sha }}/.github/workflows/codespace-review-down.yml

.github/workflows/codespace-review-up.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
gh pr comment \
108108
"$branch" \
109109
--repo "$REPO" \
110-
--body "Thank you for your pull request. I deleted the oldest codespaces to make room for a new one. You can make a new codespace by updating your pull request or closing and reopening your pull request."
110+
--body "Thank you for this pull request. I deleted the oldest codespaces to make room for a new one. You can make a new codespace by updating the pull request or closing and reopening the pull request."
111111
echo "Commented on branch $branch"
112112
done
113113
echo "Deleted the oldest $tocut codespaces"
@@ -205,18 +205,18 @@ jobs:
205205
206206
### Review this PR in a codespace 📦
207207
208-
Your codespace will be ready in two to three minutes and you can review changes at:
208+
The codespace will be ready in two to three minutes and you can review changes at:
209209
${{ env.APP_URL }}
210-
Your codespace will be automatically deleted once your pull request is closed or merged.
210+
The codespace will be automatically deleted once the pull request is closed or merged.
211211
212-
#### Your codespace will idle after 4 hours of inactivity
212+
#### The codespace will idle after 4 hours of inactivity
213213
214-
After 4 hours, you can reactivate your codespace by applying the https://github.com/${{ env.REPO }}/labels/extend-codespace label to the pull request.
215-
If the label is already applied, you can remove and reapply the label to reactivate your codespace.
214+
After 4 hours, you can reactivate the codespace by applying the https://github.com/${{ env.REPO }}/labels/extend-codespace label to the pull request.
215+
If the label is already applied, you can remove and reapply the label to reactivate the codespace.
216216
217217
<details><summary>Table of review links</summary>
218218
219-
${{ steps.changes.outputs.changesTable && 'The table shows the files in the `content` directory that were changed in this pull request. This helps you review your changes on the review server. Changes to the `data` directory are not included in this table.' || '' }}
219+
${{ steps.changes.outputs.changesTable && 'The table shows the files in the `content` directory that were changed in this pull request. Changes to the `data` directory are not included in this table.' || '' }}
220220
221221
${{ steps.changes.outputs.changesTable || '_This pull request contains code changes, so we will not generate a table of review links._' }}
222222
@@ -226,4 +226,4 @@ jobs:
226226
227227
🤖 This comment is [automatically generated][workflow].
228228
229-
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/codespace-review-up.yml
229+
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.workflow_sha }}/.github/workflows/codespace-review-up.yml

.github/workflows/review-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ jobs:
100100
101101
🤖 This comment is [automatically generated][workflow].
102102
103-
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/.github/workflows/review-comment.yml
103+
[workflow]: ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.workflow_sha }}/.github/workflows/review-comment.yml
104104
[codespace]: ${{ github.repository == 'github/docs-internal' && 'https://github.com/github/docs-team/blob/main/contributing-to-docs/use-a-codespace-to-review.md' || 'https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace' }}
105105
[local]: https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment

0 commit comments

Comments
 (0)