From a72a165518672005d9bcf195e04b02e9ac5f5e1d Mon Sep 17 00:00:00 2001 From: Alexander Hoppe Date: Mon, 21 Jul 2025 11:14:09 +0000 Subject: [PATCH] needs to be dispatch to run the latest locally --- .github/workflows/domain-replacer.yaml | 121 ++++++++++++------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/.github/workflows/domain-replacer.yaml b/.github/workflows/domain-replacer.yaml index 2cda2b7a..89458de5 100644 --- a/.github/workflows/domain-replacer.yaml +++ b/.github/workflows/domain-replacer.yaml @@ -11,22 +11,51 @@ name: domain-replacer # yamllint sees the below line as a true or false value instead of an 'on' trigger on: # yamllint disable-line rule:truthy - workflow_call: + workflow_dispatch: jobs: + # replacedomain: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout main branch + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + + # - name: Create orphan branch and clean workspace + # run: | + # git checkout --orphan domain-replacement + # git rm -rf . + # git checkout main -- . ':!./.github/workflows/domain-replacer.yaml' + + # - name: Run domain replacement + # uses: hoppea2/common-github-actions/domain-replacer@main + + # - name: Show Git Diff + # run: git diff --stat || true + + # - name: Commit and push changes + # run: | + # git config user.name "github-actions" + # git config user.email "github-actions@github.com" + + # git add . ':!./.github/workflows/' ':!./.github/actions/domain-replacer/' + + # if git diff --cached --quiet; then + # echo "No changes to commit." + # exit 0 + # fi + + # git commit -m "Replace external GitHub domain with internal Enterprise domain" + # git push --set-upstream origin domain-replacement + replacedomain: + name: Scan for external GitHub domain runs-on: ubuntu-latest + steps: - - name: Checkout main branch + - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create orphan branch and clean workspace - run: | - git checkout --orphan domain-replacement - git rm -rf . - git checkout main -- . ':!./.github/workflows/domain-replacer.yaml' - name: Run domain replacement uses: hoppea2/common-github-actions/domain-replacer@main @@ -39,64 +68,34 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - git add . ':!./.github/workflows/' ':!./.github/actions/domain-replacer/' - - if git diff --cached --quiet; then - echo "No changes to commit." - exit 0 + if git ls-remote --exit-code --heads origin domain-replacement; then + echo "Branch 'domain-replacement' exists. Checking it out." + git fetch origin domain-replacement + git checkout domain-replacement + else + echo "Branch 'domain-replacement' does not exist. Creating it." + git checkout -b domain-replacement fi - - git commit -m "Replace external GitHub domain with internal Enterprise domain" - git push --set-upstream origin domain-replacement -# jobs: - -# replacedomain: -# name: Scan for external GitHub domain -# runs-on: ubuntu-latest - -# steps: -# - name: Checkout code -# uses: actions/checkout@v4 - -# - name: Run domain replacement -# uses: hoppea2/common-github-actions/domain-replacer@main - -# - name: Show Git Diff -# run: git diff --stat || true - -# - name: Commit and push changes -# run: | -# git config user.name "github-actions" -# git config user.email "github-actions@github.com" - -# if git ls-remote --exit-code --heads origin domain-replacement; then -# echo "Branch 'domain-replacement' exists. Checking it out." -# git fetch origin domain-replacement -# git checkout domain-replacement -# else -# echo "Branch 'domain-replacement' does not exist. Creating it." -# git checkout -b domain-replacement -# fi -# # Remove workflow file from the branch to avoid permission issues -# git rm --cached .github/workflows/domain-replacer.yaml || true + # Remove workflow file from the branch to avoid permission issues + git rm --cached .github/workflows/domain-replacer.yaml || true -# # Unstage any workflow or action files -# git reset .github/workflows/ -# git reset .github/workflows/domain-replacer/ + # Unstage any workflow or action files + git reset .github/workflows/ + git reset .github/workflows/domain-replacer/ -# # Add everything else -# git add . ':!./.github/workflows/' ':!./.github/workflows/domain-replacer/' + # Add everything else + git add . ':!./.github/workflows/' ':!./.github/workflows/domain-replacer/' -# if git diff --cached --quiet; then -# echo "No changes to commit." -# exit 0 -# fi + if git diff --cached --quiet; then + echo "No changes to commit." + exit 0 + fi -# git commit -m "Replace external GitHub domain with internal Enterprise domain" -# git pull --rebase origin domain-replacement || true -# git push --force-with-lease origin domain-replacement + git commit -m "Replace external GitHub domain with internal Enterprise domain" + git pull --rebase origin domain-replacement || true + git push --force-with-lease origin domain-replacement - name: Install GitHub CLI