Skip to content

Commit ed72521

Browse files
committed
test version
1 parent a202867 commit ed72521

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

.github/workflows/gh-pages.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ jobs:
142142
id: find_files
143143
run: |
144144
VERSION=${{ env.VERSION }}
145-
# Locate all files matching the VERSION
146145
files=($(ls ./*${VERSION}* 2>/dev/null || echo ""))
147146
if [ ${#files[@]} -eq 0 ]; then
148147
echo "Error: No files found matching VERSION ${VERSION}"
149148
exit 1
150149
fi
151-
"file=${files[@]}" >> $GITHUB_ENV
150+
for file in "${files[@]}"; do
151+
echo "file=$file" >> $GITHUB_ENV
152+
done
152153
echo "Found files: ${files[@]}"
153154
env:
154155
VERSION: ${{ env.VERSION }}

src/component/TransferFunc.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,26 +121,28 @@ class TransferFunc extends Component {
121121
const repoName = 'TxDOT';
122122
const branch = 'main';
123123

124-
const getFileSHA = async () => {
124+
const getFileSHA = async (filePath) => {
125125
try {
126126
const res = await axios.get(
127-
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}?ref=${branch}`, {
127+
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}?ref=${branch}`,
128+
{
128129
headers: {
129130
Authorization: `token ${token}`,
130131
},
131132
}
132133
);
133-
return res.data.sha;
134+
return res.data.sha; // File exists, return its SHA
134135
} catch (err) {
135-
console.warn('File does not exist, creating a new one');
136-
return null; // File doesn't exist, so no SHA to pass
136+
console.warn(`${filePath} does not exist, creating a new one`);
137+
return null; // File doesn't exist, return null to create a new file
137138
}
138139
};
139140

140141
this.setState({
141142
loading: true
142143
});
143-
const sha = await getFileSHA();
144+
const shaTransferFuncVar = await getFileSHA(filePath);
145+
const shaPackageJson = await getFileSHA('package.json');
144146
this.setState({
145147
loading: false
146148
}); // Reset loading after the request is done
@@ -163,8 +165,9 @@ class TransferFunc extends Component {
163165
try {
164166
const response = await axios.put(
165167
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/${filePath}`, {
166-
message: sha ? 'Update TransferFuncVar.js file' : 'Create TransferFuncVar.js file',
168+
message: shaTransferFuncVar ? 'Update TransferFuncVar.js file' : 'Create TransferFuncVar.js file',
167169
content: content,
170+
sha: shaTransferFuncVar,
168171
branch: branch,
169172
}, {
170173
headers: {
@@ -177,6 +180,7 @@ class TransferFunc extends Component {
177180
`https://api.github.com/repos/${repoOwner}/${repoName}/contents/package.json`, {
178181
message: 'Update package.json version',
179182
content: contentPackageJson,
183+
sha: shaPackageJson,
180184
branch: branch,
181185
}, {
182186
headers: {
@@ -188,6 +192,7 @@ class TransferFunc extends Component {
188192

189193
// Show success alert
190194
alert('File uploaded successfully!');
195+
this.props.toMenu();
191196
} catch (error) {
192197
console.error('Error uploading file', error);
193198

0 commit comments

Comments
 (0)