From 2057d574e28df46647b871d9a31e1d42989ee0a1 Mon Sep 17 00:00:00 2001 From: okamsn Date: Thu, 7 Mar 2024 19:05:56 -0500 Subject: [PATCH] Improve auto-commits to copied branches. - Add a branch that only contains the `loopy` package. - Use the copied commit's message in the new commit. --- .../workflows/automatic-pr-to-dash-copy.yml | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/workflows/automatic-pr-to-dash-copy.yml b/.github/workflows/automatic-pr-to-dash-copy.yml index 4b674018..9c946dfe 100644 --- a/.github/workflows/automatic-pr-to-dash-copy.yml +++ b/.github/workflows/automatic-pr-to-dash-copy.yml @@ -15,20 +15,50 @@ jobs: - uses: actions/checkout@v3 with: ref: master - path: loopy + path: loopy-master - uses: actions/checkout@v3 with: ref: loopy-dash-only - path: loopy-dash - - name: Copy file to directory - run: cp loopy/loopy-dash.el loopy-dash/loopy-dash.el - - name: Commit new changes and push. + path: loopy-dash-only + - uses: actions/checkout@v3 + with: + ref: loopy-only + path: loopy-only + - name: Copy commit message + run: | + cd loopy-master + git log \ + --format='(GitHub Action) %s%n%nThis commit was copied from the master branch.%n%nCommit: %H%nAuthor: %an <%ae>%nDate: %ai%n%n%B' \ + -n 1 --no-color --encoding=utf8 HEAD > ../commit-msg.txt + cd .. + - name: Copy file "loopy-dash.el" to directory "loopy-dash-only" + run: cp loopy-master/loopy-dash.el loopy-dash-only/loopy-dash.el + - name: Commit new changes and push for loopy-dash-only. run: | - cd loopy-dash + cd loopy-dash-only git config --local user.name "github-actions[bot]" git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git add --force loopy-dash.el - git commit --allow-empty -m "Automatic commit of changes from master branch." + git commit --allow-empty -F ../commit-msg.txt + git push + cd .. + env: + USERNAME: github-actions[bot] + - name: Copy all other files to directory "loopy-only" + run: | + shopt -u dotglob + cd loopy-master + rm -rf .git*/** + rm loopy-seq.el + cp -t ../loopy-only -r ** + cd .. + - name: Commit new changes and push for loopy-only. + run: | + cd loopy-only + git config --local user.name "github-actions[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add --force . + git commit --allow-empty -F ../commit-msg.txt git push env: USERNAME: github-actions[bot]