Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 70 additions & 1 deletion .github/workflows/updatemirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- ONLYOFFICE-data/build_tools_data

steps:
- name: Checkout runner workspace
- name: Mirror upstream repository
run: |
# Split repo name into owner and repo parts
IFS='/' read -r owner repo <<< "${{ matrix.repo }}"
Expand All @@ -51,3 +51,72 @@ jobs:
git push eurooffice --tags
env:
GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }}

- name: Update contributors list in README.md
run: |
IFS='/' read -r owner repo <<< "${{ matrix.repo }}"

# Clone the target repo default branch to update README
git clone --depth 1 "https://x-access-token:${{ env.GITHUB_TOKEN }}@github.com/Euro-Office/${repo}.git" "target-${repo}"
cd "target-${repo}"

# Identify README file
README_FILE=$(find . -maxdepth 1 -iname "readme.md" -print -quit)
[ -z "$README_FILE" ] && README_FILE="README.md"
[ ! -f "$README_FILE" ] && touch "$README_FILE"

# Remove existing contributors section and append updated list
sed -i '/## Contributors/,$d' "$README_FILE"
{
echo ""
echo "## Contributors"
echo "A huge thank you to all the contributors of the upstream repository!"
echo ""
gh api "repos/${{ matrix.repo }}/contributors" --jq '.[] | select(.type != "Bot") | "- [" + .login + "](" + .html_url + ")"'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Paginate contributor API requests before writing README

Both contributor list updates call gh api .../contributors without pagination, so only the first page is processed; the gh api manual states that --paginate is required to fetch all pages. As a result, repositories with more than one page of non-bot contributors will have incomplete contributor sections, which undermines the stated goal of maintaining a full contributor list.

Useful? React with 👍 / 👎.

} >> "$README_FILE"

# Commit and push changes
git config user.name "Euro-Office Robot"
git config user.email "eo-robot@users.noreply.github.com"
git add "$README_FILE"
if ! git diff --cached --quiet; then
git commit -m "chore: update contributors list in $README_FILE"
git push origin HEAD
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop pushing README commits to mirrored default branches

In build you now commit and push README changes directly to each mirrored repo (git push origin HEAD), but the same job still starts by mirroring upstream with a non-force git push eurooffice --all. After the first run that creates a README-only commit, the next run will hit non-fast-forward rejections for that branch because upstream does not contain that commit, causing the mirror step to fail for affected repos. This makes the scheduled mirror workflow self-breaking unless these README commits are isolated from mirrored refs (or reconciled before mirroring).

Useful? React with 👍 / 👎.

fi
env:
GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }}

update-main-readme:
needs: build
runs-on: self-hosted
steps:
- name: Checkout DocumentServer
uses: actions/checkout@v3
with:
token: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }}

- name: Update contributors list in main README.md
run: |
README_FILE=$(find . -maxdepth 1 -iname "readme.md" -print -quit)
[ -z "$README_FILE" ] && README_FILE="README.md"

# Remove existing contributors section and append updated list
sed -i '/## Contributors/,$d' "$README_FILE"
{
echo ""
echo "## Contributors"
echo "A huge thank you to all the contributors of Euro-Office!"
echo ""
gh api "repos/${{ github.repository }}/contributors" --jq '.[] | select(.type != "Bot") | "- [" + .login + "](" + .html_url + ")"'
} >> "$README_FILE"

# Commit and push changes
git config user.name "Euro-Office Robot"
git config user.email "eo-robot@users.noreply.github.com"
git add "$README_FILE"
if ! git diff --cached --quiet; then
git commit -m "chore: update contributors list in $README_FILE"
git push origin HEAD
fi
env:
GITHUB_TOKEN: ${{ secrets.EURO_OFFICE_MIRROR_TOKEN }}