Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement the action based on godo and make it more orchestratable #114

Merged
merged 10 commits into from
Jul 31, 2024
7 changes: 4 additions & 3 deletions delete/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func main() {
a.Fatalf("failed to get GitHub context: %v", err)
}

do := godo.NewFromToken(in.token).Apps
do := godo.NewFromToken(in.token)
do.UserAgent = "do-app-action-delete"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to add a version of the action here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the proper version might be tricky, outside of manually updating it. I'll try to see if we can get the commit SHA added easily though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried for a bit and it seems like the action isn't checked out as a git repository. There's an action_ref field on the Github context that contains the reference the user used to fetch the action but that also feel kinda meh tbh.

The most reliable way would likely be to hardcode and keep updating it, though I also don't love that 😓 . I'll move forward as-is though, we can enhance this further down the line as we see fit.


appID := in.appID
if appID == "" {
Expand All @@ -39,7 +40,7 @@ func main() {
appName = utils.GenerateAppName(repoOwner, repo, ghCtx.RefName)
}

app, err := utils.FindAppByName(ctx, do, appName)
app, err := utils.FindAppByName(ctx, do.Apps, appName)
if err != nil {
a.Fatalf("failed to find app: %v", err)
}
Expand All @@ -53,7 +54,7 @@ func main() {
appID = app.ID
}

if resp, err := do.Delete(ctx, appID); err != nil {
if resp, err := do.Apps.Delete(ctx, appID); err != nil {
if resp.StatusCode == http.StatusNotFound && in.ignoreNotFound {
a.Infof("app %q not found, ignoring", appID)
return
Expand Down
4 changes: 3 additions & 1 deletion deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ func main() {
// Mask the DO token to avoid accidentally leaking it.
a.AddMask(in.token)

do := godo.NewFromToken(in.token)
do.UserAgent = "do-app-action-deploy"
d := &deployer{
action: a,
apps: godo.NewFromToken(in.token).Apps,
apps: do.Apps,
httpClient: http.DefaultClient,
inputs: in,
}
Expand Down
Loading