Skip to content

Instantly share code, notes, and snippets.

@filiptronicek
Created October 11, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filiptronicek/3f90a559dbbbbe669085504d958d0b3a to your computer and use it in GitHub Desktop.
Save filiptronicek/3f90a559dbbbbe669085504d958d0b3a to your computer and use it in GitHub Desktop.
Get current Vercel deploy commit sha on your website
export default async (_req, res) => {
res.json({ data: process.env.VERCEL_GITHUB_COMMIT_SHA });
};
const commitSp = document.getElementById("commit");
const getCommit = () => {
const url = `/api/commit`;
const website = `https://github.com/filiptronicek/trnck.dev`;
fetch(url)
.then((responce) => responce.json())
.then((res) => {
commitSp.innerHTML = `<a href="${website}/commit/${
res.data
}" target="_blank" rel="noreferrer">${res.data.substring(0, 7)}</a>`;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment