mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
@@ -0,0 +1,29 @@
|
|||||||
|
name: Latest Dev Commit
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-hash:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get latest commit hash
|
||||||
|
id: vars
|
||||||
|
run: echo "::set-output name=commit_hash::$(git rev-parse HEAD)"
|
||||||
|
|
||||||
|
- name: Update latest_dev_commit.txt
|
||||||
|
run: echo "${{ steps.vars.outputs.commit_hash }}" > ./public/latest_dev_commit.txt
|
||||||
|
|
||||||
|
- name: Commit and push
|
||||||
|
run: |
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git add ./public/latest_dev_commit.txt
|
||||||
|
git commit -m "Update latest_dev_commit.txt with latest commit hash"
|
||||||
|
git push
|
||||||
+15
-4
@@ -25,6 +25,7 @@ import useError from "./hooks/useError";
|
|||||||
import useInfo from "./hooks/useInfo";
|
import useInfo from "./hooks/useInfo";
|
||||||
import useSuccess from "./hooks/useSuccess";
|
import useSuccess from "./hooks/useSuccess";
|
||||||
import packageJson from '../package.json';
|
import packageJson from '../package.json';
|
||||||
|
const commitRef = process?.env?.REACT_APP_COMMIT_REF || '';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const {
|
const {
|
||||||
@@ -70,20 +71,30 @@ export default function App() {
|
|||||||
try {
|
try {
|
||||||
const packageRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/master/package.json', { cache: 'no-cache' });
|
const packageRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/master/package.json', { cache: 'no-cache' });
|
||||||
const packageData = await packageRes.json();
|
const packageData = await packageRes.json();
|
||||||
|
|
||||||
if (packageJson.version !== packageData.version) {
|
if (packageJson.version !== packageData.version) {
|
||||||
const newVersionInfo = `New version available, plebchan v${packageData.version}. Refresh the page to update.`;
|
const newVersionInfo = `New version available, plebchan v${packageData.version}. Refresh the page to update.`;
|
||||||
localStorage.setItem('infoToast', newVersionInfo);;
|
localStorage.setItem('infoToast', newVersionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for commit hash if commitRef is defined
|
||||||
|
if (commitRef.length > 0) {
|
||||||
|
const commitRes = await fetch('https://raw.githubusercontent.com/plebbit/plebchan/development/public/latest_dev_commit.txt', { cache: 'no-cache' });
|
||||||
|
const latestCommit = await commitRes.text();
|
||||||
|
|
||||||
|
if (latestCommit.trim() !== commitRef.trim()) {
|
||||||
|
const newVersionInfo = `New dev version available, commit ${latestCommit}. Refresh the page to update.`;
|
||||||
|
localStorage.setItem('infoToast', newVersionInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch latest version info:', error);
|
console.error('Failed to fetch latest version info:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchVersionInfo();
|
fetchVersionInfo();
|
||||||
}, [setNewInfoMessage]);
|
}, [setNewInfoMessage]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// preload banners
|
// preload banners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user