Update forwardport.yml #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Forward Port Data | |
| on: | |
| push: | |
| branches: | |
| - "6-1.16.2-1.16.5" | |
| - "7-1.17-1.17.1" | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| forward-port: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Define sync rules | |
| id: vars | |
| run: | | |
| # 6 -> 7, 9, master | |
| if [[ "${GITHUB_REF_NAME}" == "6-1.16.2-1.16.5" ]]; then | |
| echo "targets=7-1.17-1.17.1 9-1.18.2 master" >> $GITHUB_OUTPUT | |
| echo "datadir=data/extrarecipe/recipes/6-1.16.2-1.16.5" >> $GITHUB_OUTPUT | |
| fi | |
| # 7 -> 9, master | |
| if [[ "${GITHUB_REF_NAME}" == "7-1.17-1.17.1" ]]; then | |
| echo "targets=9-1.18.2 master" >> $GITHUB_OUTPUT | |
| echo "datadir=data/extrarecipe/recipes/7-1.17-1.17.1" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Forward port data directory | |
| run: | | |
| targets=(${{ steps.vars.outputs.targets }}) | |
| datadir="${{ steps.vars.outputs.datadir }}" | |
| for TO in "${targets[@]}"; do | |
| echo "Syncing: ${datadir} -> data/recipes/$TO" | |
| BRANCH="fp-${GITHUB_REF_NAME}-to-$TO-$(date +%s)" | |
| git checkout -b $BRANCH | |
| mkdir -p "data/recipes/$TO" | |
| cp -r "$datadir/"* "data/recipes/$TO/" || true | |
| git add "data/recipes/$TO" | |
| git commit -m "Forward-port data: ${GITHUB_REF_NAME} to $TO" || true | |
| git push origin $BRANCH || true | |
| gh pr create \ | |
| --title "Forward-port data: ${GITHUB_REF_NAME} to $TO" \ | |
| --body "Auto sync data/recipes from ${GITHUB_REF_NAME} to ${TO}." \ | |
| --base $TO \ | |
| --head $BRANCH || true | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |