Link application repository PR and the PipeCD deployment related to it.
What would you like to be added:
When separating the app code repo and manifests repo by using event watcher, it would be nice to link the app repo PR and PipeCD deployment.
Why is this needed:
There are some use cases. For example,
- rollback the app code repo quickly when the incident occurs.
- record the time from when a PR is closed until the PipeCD deployment is triggered
I investigated the plan to solve this issue.
Pre-condition:
- The event operation flow is as follows, so we can only use the commit information of the manifest repository for the deployment operation.
- Commit to the Application repository
pipe-cd/actions-event-registeris invoked- In this action,
pipectl event registeris invoked
- In this action,
- piped receives the event from the control plane server and commits to the manifest repository
- piped pull the manifest repository and detect changes
- piped deploy changes to the infrastructure, we can use only the information of the pulled commits.
- We can use the
text/templatefeature in the commit message through the event GIT_UPDATE; this is undocumented.- https://github.com/pipe-cd/pipecd/blob/713fb032551ce01dd8d15c3ffa7063d91cf4cca1/pkg/app/piped/eventwatcher/eventwatcher.go#L772-L789
Plan:
Overview:
Pass the context information through actions-event-register -> pipectl -> control-plane-server -> piped -> manifest repo -> piped
Detail
- collect GitHub repo/commit context in actions-event-register
- create a new option
--contextto the pipectl and pass contexts to it - add
map<string,string> contexthere and pass contexts- https://github.com/pipe-cd/pipecd/blob/713fb032551ce01dd8d15c3ffa7063d91cf4cca1/pkg/app/server/service/apiservice/service.proto#L228-L232
- add
map<string,string> contexthere and store contexts- https://github.com/pipe-cd/pipecd/blob/713fb032551ce01dd8d15c3ffa7063d91cf4cca1/pkg/model/event.proto#L29-L55
- add
Context map[string]stringhere and pass contexts- https://github.com/pipe-cd/pipecd/blob/713fb032551ce01dd8d15c3ffa7063d91cf4cca1/pkg/app/piped/eventwatcher/eventwatcher.go#L766-L770
- add a document about the
text/templatefeature of the GIT_UPDATE event - finally, users can use
{{ .Context.GITHUB_SHA }}or something like this in the commit message format through the GIT_UPDATE event config so that users can use the application repository context in the deployment SCRIPT_RUN stage or from the webhook.
📝 It might be useful to add some metadata as git trailer https://git-scm.com/docs/git-interpret-trailers#_description
We will fix actions-event-register after releasing this fix. Follow https://github.com/pipe-cd/pipecd/issues/5307 for it.