forked from dell/common-github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (75 loc) · 3.08 KB
/
domain-replacer.yaml
File metadata and controls
91 lines (75 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# 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
on:
workflow_call:
jobs:
replacedomain:
name: Scan for external GitHub domain URLs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Replace github.com/dell/ with eos2git.cec.lab.emc.com/CSM/
run: |
echo "Scanning for files to update..."
find . -type f ! -name "go.sum" | 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
- 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
# # Add everything else
# # git add . ':!./.github/workflows/'
# git add .
# 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
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Replace external GitHub domain with internal Enterprise domain
title: Replace external GitHub domain
body: This PR replaces all references to github.com/dell/ with eos2git.cec.lab.emc.com/CSM/
branch: domain-replacement
base: main
# - 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 }}