Skip to content

Commit

Permalink
fix(resource_github_actions_environment_secret): handle 404 on repo r…
Browse files Browse the repository at this point in the history
…ead (#2323)

Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com>
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
  • Loading branch information
3 people authored Oct 7, 2024
1 parent a6be28b commit 4cb5474
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions github/resource_github_actions_environment_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ func resourceGithubActionsEnvironmentSecretRead(d *schema.ResourceData, meta int

repo, _, err := client.Repositories.Get(ctx, owner, repoName)
if err != nil {
if ghErr, ok := err.(*github.ErrorResponse); ok {
if ghErr.Response.StatusCode == http.StatusNotFound {
log.Printf("[INFO] Removing environment secret %s from state because it no longer exists in GitHub",
d.Id())
d.SetId("")
return nil
}
}
return err
}

Expand Down

0 comments on commit 4cb5474

Please sign in to comment.