Skip to content

Commit f102098

Browse files
committed
Merge branch 'feature/gc'
2 parents 9cce9b6 + ce2eae0 commit f102098

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed

.github/workflows/build-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
55

6-
name: Build website
6+
name: 'Deploy website'
77

88
on:
99
push:

.github/workflows/garbage-collect.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright (c) godot-rust; Bromeon and contributors.
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
name: 'Garbage collect'
7+
8+
on:
9+
# Periodic once a day at 4am UTC
10+
schedule:
11+
- cron: '0 4 * * *'
12+
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
19+
jobs:
20+
remove-closed-prs:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: "Checkout"
24+
uses: actions/checkout@v4
25+
with:
26+
ref: doc-output
27+
28+
- name: "Import delete.sh from master"
29+
run: |
30+
git fetch origin master:master
31+
git restore --source master documentation/delete.sh
32+
33+
- name: "Identify which PRs are closed"
34+
run: |
35+
# Look in docs/gdext and docs/gdnative repo for all directories starting with "pr-", e.g. "pr-1234".
36+
# Then, issue a GitHub API request to the repo (name of parent directory, "gdext" or "gdnative") to check if the PR is closed.
37+
# If closed, remove the directory.
38+
deletedPrList=( )
39+
for repo in gdext gdnative; do
40+
echo ""
41+
echo "Search in repo $repo..."
42+
for dir in $(find "docs/$repo" -mindepth 1 -maxdepth 1 -type d -name "pr-*"); do
43+
prNum=$(basename $dir | sed -E "s/pr-//")
44+
restResult=$(curl --fail -s "https://api.github.com/repos/godot-rust/$repo/pulls/$prNum")
45+
#echo " REST response: $restResult"
46+
prState=$(echo "$restResult" | jq -r .state)
47+
echo "* PR #$prNum is $prState"
48+
if [[ "$prState" == "closed" ]]; then
49+
deletedPrList+=( "$repo/$prNum" )
50+
date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
51+
echo " > Delete PR $dir! Date: $date"
52+
bash documentation/delete.sh "$repo" "$prNum" "$date"
53+
fi
54+
done
55+
done
56+
57+
# Store deleted list in environment variable DELETED_PR_LIST, with ", " as separator.
58+
deletedPrString="${deletedPrList[*]}"
59+
echo "DELETED_PR_LIST=$deletedPrString" >> "$GITHUB_ENV"
60+
61+
# Some duplication with commit.sh, but integrating gc into commit.sh would mean big refactor...
62+
# Or we run sequential delete commits per PR.
63+
- name: "Commit and push changes"
64+
if: env.DELETED_PR_LIST != ''
65+
run: |
66+
echo "$PRE push to 'doc-output' branch..."
67+
git config user.name "Godot-Rust Automation"
68+
git config user.email "[email protected]"
69+
git commit -am "GC closed PRs: $DELETED_PR_LIST"
70+
git push origin HEAD:doc-output
71+
72+
# If there have been newer commits for the same branch/PR, skip remaining tasks.
73+
# Env var SKIP_WEBSITE_DEPLOY is set by the commit.sh script.
74+
- name: "Construct JSON"
75+
if: env.DELETED_PR_LIST != ''
76+
run: |
77+
payload=$(cat <<HEREDOC
78+
{
79+
"op": "gc",
80+
"repo": "*",
81+
"num": "*"
82+
}
83+
HEREDOC)
84+
echo "VAR=$payload"
85+
echo "PAYLOAD_JSON<<HEREDOC" >> $GITHUB_ENV
86+
echo "${payload}" >> $GITHUB_ENV
87+
echo "HEREDOC" >> $GITHUB_ENV
88+
89+
- name: "Print payload"
90+
if: env.DELETED_PR_LIST != ''
91+
run: |
92+
echo "$PAYLOAD_JSON"
93+
94+
- name: "Trigger website build"
95+
if: env.DELETED_PR_LIST != ''
96+
uses: peter-evans/repository-dispatch@v2
97+
with:
98+
event-type: 'Deploy docs'
99+
client-payload: ${{ env.PAYLOAD_JSON }}
100+

.github/workflows/update-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
55

6-
name: Update docs
6+
name: 'Generate docs'
77

88
on:
99
repository_dispatch:

0 commit comments

Comments
 (0)