From 9a04ca5c6ec65bdc988c3cd36db6b26330f0143a Mon Sep 17 00:00:00 2001 From: chiefmikey Date: Mon, 22 Aug 2022 14:19:08 -0600 Subject: [PATCH 1/2] Add beta branch commit --- .github/workflows/beta-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/beta-build.yml b/.github/workflows/beta-build.yml index 648fd649..fb16adf4 100644 --- a/.github/workflows/beta-build.yml +++ b/.github/workflows/beta-build.yml @@ -45,8 +45,8 @@ jobs: git config user.name "chiefmikey" git config user.email "wolfemikl@gmail.com" git remote set-url --add --push origin https://github.com/chiefmikey/gitlang-beta.git - echo remote-test: $(git remote -v) git add . + git commit -am 'Beta Files' git reset $(git commit-tree HEAD^{tree} -m 'Beta Branch') git push -fu origin HEAD:refs/heads/${BRANCH} echo "https://beta.gitlang.net" From be6bf5b0aa63a9ebd366ff6484a8df69c54c18de Mon Sep 17 00:00:00 2001 From: chiefmikey Date: Mon, 22 Aug 2022 15:02:25 -0600 Subject: [PATCH 2/2] Add workflow to prune beta branches --- .../{beta-build.yml => build-beta.yml} | 4 +- .../{prod-build.yml => build-prod.yml} | 6 +-- .github/workflows/prune-beta.yml | 51 +++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) rename .github/workflows/{beta-build.yml => build-beta.yml} (96%) rename .github/workflows/{prod-build.yml => build-prod.yml} (94%) create mode 100644 .github/workflows/prune-beta.yml diff --git a/.github/workflows/beta-build.yml b/.github/workflows/build-beta.yml similarity index 96% rename from .github/workflows/beta-build.yml rename to .github/workflows/build-beta.yml index fb16adf4..1d7dab71 100644 --- a/.github/workflows/beta-build.yml +++ b/.github/workflows/build-beta.yml @@ -1,4 +1,4 @@ -name: Beta Build +name: Build Beta on: pull_request: @@ -39,7 +39,7 @@ jobs: mv beta/beta-compile.yml beta/beta-branch.yml .github/workflows/ mv beta/index.html beta/404.html beta/CNAME docs/ - - name: Push to Beta + - name: Push Beta run: | BRANCH=${{ github.head_ref }} git config user.name "chiefmikey" diff --git a/.github/workflows/prod-build.yml b/.github/workflows/build-prod.yml similarity index 94% rename from .github/workflows/prod-build.yml rename to .github/workflows/build-prod.yml index 69d9c10e..1df03f12 100644 --- a/.github/workflows/prod-build.yml +++ b/.github/workflows/build-prod.yml @@ -1,4 +1,4 @@ -name: Production Build +name: Build Production on: push: @@ -28,7 +28,7 @@ jobs: npm install NODE_ENV=production NODE_OPTIONS=--loader=ts-node/esm webpack --mode production - - name: Prune + - name: Prune Files run : | prune() { echo "${1}"; @@ -45,7 +45,7 @@ jobs: export -f prune find . -maxdepth 1 | while read file; do prune ${file}; done - - name: Push + - name: Push Client run: | git config user.name "chiefmikey" git config user.email "wolfemikl@gmail.com" diff --git a/.github/workflows/prune-beta.yml b/.github/workflows/prune-beta.yml new file mode 100644 index 00000000..c4882314 --- /dev/null +++ b/.github/workflows/prune-beta.yml @@ -0,0 +1,51 @@ +name: Prune Beta + +on: + pull_request: + types: + - closed + +jobs: + prune: + if: github.event.pull_request.merged == true + name: Prune + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '16.x' + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: List Merged + run: | + FORMAT="%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(end)" + MERGED_BRANCHES=$(git branch --list --format ${FORMAT}) + + - name: Checkout Beta + uses: actions/checkout@v3 + with: + token: ${{ secrets.DISPATCH_REPO }} + repository: chiefmikey/gitlang-beta + fetch-depth: 0 + + - name: Delete Merged + run: | + BRANCH=${{ github.head_ref }} + BRANCHES=$(git branch --list) + echo test merged: ${MERGED_BRANCHES} + echo test branch: ${BRANCH} + echo test branches: ${BRANCHES} + for branch in $(echo ${BRANCHES}); do + if [ -z "${MERGED_BRANCHES##*${branch}*}" ] || [ -z "${BRANCH##*${branch}*}" ]; then + echo "Delete ${branch}" + git push origin --delete ${branch} + fi + done