Skip to content

Commit e6d3710

Browse files
authored
Add commit hash to the getZipUid function for PR Builds (#319)
* Add commit hash to the get_zip_uid function * Some fix and add comment for the change * Change the method to get last commit hash * changed method to get commit hash in netlify functions * Second-try * Add COMMIT_REF as the env value for netlify build command * update netlify.toml * Test the access of netlify variables * chaneg context of the functions for accessing the env variables * Change the netlify functions for colab and nebari to add commit hash for PR builds * Reduce the size of commit hash to 16 characters for colab and nebari js PR builds * remove bug * Bug fixes
1 parent 9f1a200 commit e6d3710

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

functions/colab.js

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.handler = async function (event, _) {
1111
const template = `ignite-${data.template}`
1212
const nbName = `${template}.ipynb`
1313
const { zipRes, nbUid } = await getZip_Uid(data)
14+
1415
const argparser = data.argparser
1516
const title = template
1617
.replace('ignite-', '')

functions/utils.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ export async function getZip_Uid(data) {
8282
// it can't be used to generate a UUID
8383
const content = await zip.generateAsync({ type: 'base64' })
8484
// we generate an unique id from the current config for pushing to github
85-
const nbUid = uuidv5(fullCode, uuidv5.URL)
85+
let nbUid = uuidv5(fullCode, uuidv5.URL)
86+
87+
const isPRBuild = process.env.PR_BUILD === 'true'
88+
const commit_sub = data.commit.substring(0, 15)
89+
90+
// To check if PR_Build = true and then add commit hash[16 characters]
91+
if (isPRBuild) {
92+
nbUid = nbUid + '-' + commit_sub
93+
}
94+
8695
const zipRes = await pushToGitHub(content, `${template}.zip`, nbUid)
8796
return {
8897
zipRes: zipRes,

src/components/NavColab.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export default {
9494
code: store.code,
9595
template: store.config.template,
9696
config: store.config,
97-
argparser: store.config.argparser
97+
argparser: store.config.argparser,
98+
commit: store.commit
9899
})
99100
})
100101
// response body is plain text

src/components/NavNebari.vue

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export default {
166166
code: store.code,
167167
template: store.config.template,
168168
config: store.config,
169+
commit: store.commit,
169170
argparser: store.config.argparser,
170171
nebariInstanceLink: hubUrl.value,
171172
userName: userName.value

src/store.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export const default_config = {
5757
export const store = reactive({
5858
code: {},
5959
config: default_config,
60-
codeUrl: ''
60+
codeUrl: '',
61+
commit: commit
6162
})
6263

6364
/**

0 commit comments

Comments
 (0)