Skip to content

feat(documentator): requirements command will dump requirements for… #438

feat(documentator): requirements command will dump requirements for…

feat(documentator): requirements command will dump requirements for… #438

Workflow file for this run

name: Sync Packages
on:
push:
branches:
- 'main'
- '[0-9]+.x'
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
settings:
name: Settings
uses: ./.github/workflows/settings.yml
sync:
name: "Sync package: ${{ matrix.package }}"
runs-on: ubuntu-latest
needs:
- settings
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.settings.outputs.packages-names) }}
steps:
# Dependencies
- name: Install git-filter-repo
run: sudo -H pip3 install git-filter-repo
- name: Detect SSH Key name
id: secret
run: |
echo "name=$(echo "${{ matrix.package }}" | sed 's/-/_/')" >> $GITHUB_OUTPUT
- name: Setup SSH Key
run: |
mkdir -p ~/.ssh/
echo "${{ secrets[steps.secret.outputs.name] }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Checkout source repo
# Unfortunately I'm not sure how to use actions/checkout with `--no-single-branch`
# that is required to get all commits.
- name: Checkout src
run: |
git clone --no-single-branch "[email protected]:${{ github.repository }}.git" src
# Create package repo
# Checkout is not used because `git-filter-repo` doesn't remove the old
# removed branches (which are not needed anymore) and I don't know how
# to fix it.
- name: Create package repo
run: |
git init package
- name: Configure package repo
working-directory: package
run: |
git remote add origin "[email protected]:${{ github.repository }}-${{ matrix.package }}.git"
# Update package
#
# There is one known issue: if branch related only for one package it will
# be cloned into all other packages (and will be without commits).
#
# How to disable this behaviour?
- name: Extract commits
run: |
git-filter-repo --source=src --target=package \
--subdirectory-filter="${{ needs.settings.outputs.packages-directory }}/${{ matrix.package }}"
# Before `push --mirror` we need enable track for all branches, or they will
# not be visible after `git clone` and on the Branches page on GitHub.
#
# Thanks to https://stackoverflow.com/a/379842/7511282
- name: Setup branches
working-directory: package
run: |
for i in `git branch -a | grep remotes/origin/`;
do
git branch --track ${i#remotes/origin/} $i \
|| git branch --track ${i#remotes/origin/} --set-upstream-to=$i
done
- name: Push package
working-directory: package
run: |
git push --mirror origin