Created
October 11, 2020 19:12
-
-
Save filiptronicek/3f90a559dbbbbe669085504d958d0b3a to your computer and use it in GitHub Desktop.
Get current Vercel deploy commit sha on your website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default async (_req, res) => { | |
res.json({ data: process.env.VERCEL_GITHUB_COMMIT_SHA }); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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