-
-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (59 loc) · 1.77 KB
/
history-clear.yml
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
# #
# @type github workflow
#
# Clears the repository history
# #
name: "🧱 History › Clear"
run-name: "🧱 History › Clear"
# #
# triggers
# #
on:
# #
# Trigger > Workflow Dispatch
# #
workflow_dispatch: # Manually trigger the workflow
# #
# Trigger > Cron Schedule
# #
schedule:
- cron: '0 0 * * *'
# #
# environment variables
# #
env:
BOT_NAME_1: EuropaServ
BOT_NAME_DEPENDABOT: dependabot[bot]
# #
# jobs
# #
jobs:
reset-history:
runs-on: ubuntu-latest
steps:
- name: "Checkout the current repository"
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure that the entire history is fetched
- name: "Configure Git author identity"
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: "Remove Git history"
run: |
# Create a new orphan branch
git checkout --orphan temp-branch
# Add all files to the new branch
git add -A
# Commit the files to the new branch
git commit -m "Initial commit with current files only"
# Delete the old main branch
git branch -D main
# Rename the new orphan branch to main
git branch -m main
# Force push the new main branch to the remote repository
git push -f origin main
- name: "Clean up references"
run: |
# Remove remote-tracking references to deleted branches (optional)
git fetch origin --prune