Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/domain-replacer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Reusable workflow to update external GitHub domain references in files
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:

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/.github/workflows/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"

# Check if the branch exists remotely
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 add . ':!./.github/workflows/' ':!./.github/workflows/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 pull --rebase origin domain-replacement || true
git push --force-with-lease origin domain-replacement

- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh

- name: Create Pull Request with gh CLI
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--title "Replace external GitHub domain" \
--body "This PR replaces all references to github.com/dell/ with eos2git.cec.lab.emc.com/CSM/" \
--base main \
--head domain-replacement \
--repo ${{ github.repository }}
11 changes: 11 additions & 0 deletions domain-replacer/actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Replace External GitHub Domain
description: Replaces https://github.com/dell/ with https://eos2git.cec.lab.emc.com/CSM/

runs:
using: "composite"
steps:
- name: Run domain replacement script
shell: bash
run: |
chmod +x ${{ github.action_path }}/replace.sh
${{ github.action_path }}/replace.sh "${{ inputs.file-glob }}"
12 changes: 12 additions & 0 deletions domain-replacer/replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set -e

echo "Scanning for files to update..."


find . -type f ! -name "go.sum" ! -path "./.github/workflows/*" | while read -r file; do
echo "Checking $file"
if grep -q 'github.com/dell/' "$file"; then
echo "Updating $file"
sed -i 's|github.com/dell/|eos2git.cec.lab.emc.com/CSM/|g' "$file"
fi
done