Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/actions/graformer/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ runs:
recreate: []
};

function renderField(resourceChange, field){
const from = resourceChange.change.before && resourceChange.change.before[field];
const to = resourceChange.change.after && resourceChange.change.after[field];
if (from && to && from !== to) {
return `${from} -> ${to}`;
}
return to || from;
}

function getResourceNameFromChange(resourceChange, actualChange){
if(resourceChange.type === 'github_repository'){
return `${resourceChange.type} :: ${actualChange.name}`
Expand All @@ -117,6 +126,14 @@ runs:
return `${resourceChange.type} :: ${actualChange.repository}/${actualChange.environment} (${pattern})`;
}else if(resourceChange.type === 'github_repository_custom_property'){
return `${resourceChange.type} :: ${actualChange.repository}/${actualChange.property_name}`;
}else if(resourceChange.type === 'github_team'){
return `${resourceChange.type} :: ${renderField(resourceChange, 'name')}`;
}else if(resourceChange.type === 'github_membership'){
return `${resourceChange.type} :: ${renderField(resourceChange, 'username')} (${renderField(resourceChange, 'role')})`;
}else if(resourceChange.type === 'github_team_membership'){
const match = resourceChange.address.match(/github_team_membership\.[^.[]+\["([^"]+)"\]$/);
const membership = match ? match[1] : renderField(resourceChange, 'username');
return `${resourceChange.type} :: ${membership} (${renderField(resourceChange, 'role')})`;
} else {
return `unknown type ${resourceChange.type}. resource address: ${resourceChange.address}`
}
Expand Down
Loading