Commit 181b1cfe authored by Aral Balkan's avatar Aral Balkan
Browse files

Commits now working in data repository update.

parent 12952d03
......@@ -182,6 +182,8 @@ class GitlabWebhookServer
index = null
signature = NodeGit.Signature.create 'Blockdown Builder', 'hello+blockdown-builder@ind.ie', 123456789, 60
indexTreeOid = null
NodeGit.Repository.open app.dataDirectory
.then (repositoryResult) =>
@debug 'Update: got repository result'
......@@ -190,29 +192,42 @@ class GitlabWebhookServer
.then (indexResult) =>
@debug 'Update: got index result'
index = indexResult
# index.read 1
@info index
index.read 1 # Force a read of the index into memory.
@info index
# The ADD_CHECK_PATHSPEC should make addAll function like
# git add --all (according to https://libgit2.github.com/libgit2/#HEAD/group/index/git_index_add_all)
index.addAll '*', NodeGit.Index.ADD_OPTION.ADD_CHECK_PATHSPEC
# DEBUG: Dry run
index.addAll '*', NodeGit.Index.ADD_OPTION.ADD_CHECK_PATHSPEC, (path, matchedPathSpec, payload) =>
@info "Path:"
@info path
@info "matchedPathSpec:"
@info matchedPathSpec
@info "payload:"
@info payload
# index.addAll '*', NodeGit.Index.ADD_OPTION.ADD_CHECK_PATHSPEC, (path, matchedPathSpec, payload) =>
# @info "Path:"
# @info path
# @info "matchedPathSpec:"
# @info matchedPathSpec
# @info "payload:"
# @info payload
# return 1
.then (result) =>
@info "addAll result:"
@info index.entries()
@debug 'Update: writing (write + writeTree)'
writeResult = index.write() # sync
@info "write result: #{writeResult}"
index.writeTree()
.then (oid) =>
@debug "Update: got oid: #{oid}"
repository.createCommit 'HEAD', signature, signature, 'Latest generated content.', oid, []
.then =>
.then (writeTreeOidResult) =>
@info "Update: writeTree returned oid: #{writeTreeOidResult}"
indexTreeOid = writeTreeOidResult
# Get the parent reference in the next two steps
# (Courtesy Rafael: http://stackoverflow.com/a/28890806/253485)
NodeGit.Reference.nameToId repository, 'HEAD'
.then (head) =>
@info "Got head: #{head}"
repository.getCommit head
.then (parent) =>
@info "Got parent: #{parent}"
repository.createCommit 'HEAD', signature, signature, 'Latest generated content.', indexTreeOid, [parent]
.then (commitOidResult) =>
@info "Update: createCommit returned oid: #{commitOidResult}"
@info 'Added changes to data repository.'
NodeGit.Remote.lookup repository, 'origin'
.then (origin) =>
......@@ -222,7 +237,8 @@ class GitlabWebhookServer
# null,
# repository.defaultSignature()
# 'Push to master'
.then =>
.then (pushResult) =>
@info "Push result: #{pushResult}"
@info 'Completed update.'
module.exports = GitlabWebhookServer
......@@ -14,6 +14,8 @@ Builds the blockdown data from the blockdown content.
Note that the repositories we use for development are `content-dev` and `data-dev` and the ones we use for deployment, below, are `content` and `dev`.
4. Add your ssh key for the Blockdown repositories to `~/ind.ie.blockdown-builder/ssh` as `id_rsa` and `id_rsa.pub`.
# Deployment
1. Set up server with Dokku.
......@@ -34,3 +36,5 @@ Note that the repositories we use for development are `content-dev` and `data-de
7. Set up post-push and post-merge webhooks on Gitlab for both the Builder and Content repositories to point to `https://url/for/your/installation/build/(token-from-config.coffee)`
8. Add your ssh key for the Blockdown repositories to `~/ind.ie.blockdown-builder/ssh` as `id_rsa` and `id_rsa.pub`.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment