When GitLab Commit pushed - Add new record to Sources tab on Entity View

990990

JavaScript for action:

const branch = args.body.ref;
// Branch is smth like `refs/heads/us12355`
const match = branch.match(/^refs\/heads\/us(\d+)/);

if (match && isFinite(match[1])) {
    const entityId = parseInt(match[1]);
    const commands = args.body.commits.map(commit => {
      return {
        command: "targetprocess:CreateResource",
        payload: {
          resourceType: "Revision",
          fields: {
            Project: {Id: 994},
            SourceControlId: commit.id,
            Description: commit.message,
            CommitDate: commit.timestamp,
            Assignables: {
              Items: [{Id: entityId}]
            },
            RevisionFiles: {
              Items: commit.added.map(addedName => ({
                FileName: addedName,
                FileAction: "Add"              
              }))
            }
          }
        }
      };
    });
    return commands;
}