17
17
- name : Checkout
18
18
uses : actions/checkout@v3
19
19
20
+ - name : Copy config matrix to persist it
21
+ run : |
22
+ mkdir ../configMatrix
23
+ cp ./.github/workflows/configMatrix.sh ../configMatrix/
24
+
20
25
- name : Setup
21
26
uses : ./.github/actions/setup
22
27
27
32
- name : Create old version libraries
28
33
run : |
29
34
# Source all the configuration values to load $languages, $types, and $exclude
30
- source ./.github/workflows /configMatrix.sh
35
+ source ../configMatrix /configMatrix.sh
31
36
32
37
create_library() {
33
38
library_type=$1
49
54
--no-example \
50
55
--no-local \
51
56
--react-native-version 0.73.0-rc.2
57
+
58
+ # Remove the .git folder of the created library
59
+ rm -rf "$target_path/.git"
52
60
}
53
61
54
62
for library_type in "${libraryTypes[@]}"; do
58
66
fi
59
67
done
60
68
done
61
-
62
- - name : Fetch main
63
- run : git fetch origin main
64
-
65
- - name : Checkout main
66
- run : git checkout origin/main
67
69
68
70
# - name: Setup again # Add a check here to setup again if deps changed
69
71
# uses: ./.github/actions/setup
76
78
- name : Create library again
77
79
run : |
78
80
# Source all the configuration values to load $languages, $types, and $exclude
79
- source ./.github/workflows/configMatrix.sh
81
+ source ../configMatrix/configMatrix.sh
82
+
83
+ git fetch origin main
84
+ git checkout origin/main
80
85
81
86
create_library() {
82
87
library_type=$1
98
103
--no-example \
99
104
--no-local \
100
105
--react-native-version 0.73.0-rc.2
106
+
107
+ # Remove the .git folder of the created library
108
+ rm -rf "$target_path/.git"
101
109
}
102
110
103
111
for library_type in "${libraryTypes[@]}"; do
@@ -108,20 +116,9 @@ jobs:
108
116
done
109
117
done
110
118
111
- cd ..
112
- echo "$PWD"
113
-
114
- # - uses: webfactory/[email protected]
115
- # with:
116
- # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }}
117
-
118
- - name : Create the Differ repo
119
+ - name : Switch to diffs branch
119
120
run : |
120
- mkdir differ
121
- cd differ
122
- git init
123
- git remote add origin ${{ vars.DIFF_VIEW_SSH }}
124
- desired_branch="${{ env.NEW_VERSION_BRANCH }}"
121
+ desired_branch="diffs"
125
122
# Check if the branch exists on the remote repository
126
123
if git ls-remote --heads origin "$desired_branch" | grep -q "$desired_branch"; then
127
124
echo "The branch $desired_branch already exists on the remote repository."
@@ -132,6 +129,82 @@ jobs:
132
129
git checkout -b "$desired_branch" # Create a new branch and switch to it
133
130
fi
134
131
132
+ - name : Initiate diffs
133
+ run : |
134
+ # Source all the configuration values to load $languages, $types, and $exclude
135
+ source ../configMatrix/configMatrix.sh
136
+
137
+ output_path="../output"
138
+ output_file="$output_path/output.txt"
139
+
140
+ mkdir -p "$output_path"
141
+
142
+ function copy_commit_diff(){
143
+ library_type=$1
144
+ language=$2
145
+
146
+ path_prefix="../test/$library_type/$language"
147
+ target_path_new_version="$path_prefix/new-version"
148
+ target_path_old_version="$path_prefix/old-version"
149
+
150
+ # Remove everything except the .git folder
151
+ for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done;
152
+
153
+ # Copy the old version
154
+ cp -r "$target_path_old_version/." .
155
+
156
+ git config --global user.email "[email protected] "
157
+ git config --global user.name "Github actions test"
158
+
159
+ # Add all files and commit
160
+ git add -A || true && git commit -m "Automatic commit" || true
161
+
162
+ # Remove everything except the .git folder
163
+ for i in $(ls | grep -v ".git") ; do rm -rf "$i"; done;
164
+
165
+ # Copy the new version
166
+ cp -r "$target_path_new_version/." .
167
+
168
+ # Add all files and commit
169
+ git add -A || true && git commit -m "Automatic commit" || true
170
+
171
+ # echo diff
172
+ echo $(git diff HEAD~)
173
+
174
+ # Check if there is a diff
175
+ if git diff --quiet HEAD~; then
176
+ echo "No diff"
177
+ else
178
+ # Push the branches
179
+ git push --set-upstream origin diffs
180
+
181
+ # Get new version remote commit hash
182
+ new_version_commit_hash=$(git rev-parse --short origin/diffs)
183
+
184
+ # Get old version remote commit hash
185
+ old_version_commit_hash=$(git rev-parse --short origin/diffs~)
186
+
187
+ # Add output to file
188
+ echo "[$library_type/$language](https://github.com/${{github.repository}}/compare/$old_version_commit_hash..$new_version_commit_hash)" >> "$output_file"
189
+
190
+ # Add empty line
191
+ echo \ >> $output_file
192
+ fi
193
+ }
194
+
195
+ for library_type in "${libraryTypes[@]}"; do
196
+ for language in "${languages[@]}"; do
197
+ if [[ ! "${exclude[*]}" =~ ${library_type}/${language} ]]; then
198
+ copy_commit_diff "$library_type" "$language"
199
+ fi
200
+ done
201
+ done
202
+
203
+
204
+ # - uses: webfactory/[email protected]
205
+ # with:
206
+ # ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }}
207
+
135
208
- name : Clean the Differ repo
136
209
run : |
137
210
cd differ
0 commit comments