@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 "github.com/google/go-github/v81/github"
13+ "github.com/hashicorp/terraform-plugin-log/tflog"
1314 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1415 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
1516 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -756,6 +757,24 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
756757 d .SetId (repo .GetName ())
757758 }
758759
760+ archived := d .Get ("archived" ).(bool )
761+ if archived {
762+ tflog .Debug (ctx , "Repository archived, skipping modifying topics, pages, visibility, and vulnerability alerts" , map [string ]any {
763+ "owner" : meta .(* Owner ).name ,
764+ "repository" : d .Id (),
765+ "archived" : archived ,
766+ })
767+ // Archived is not set on Repository.Create, so we need to PATCH the repository to set it
768+ repo , _ , err := client .Repositories .Edit (ctx , owner , repoName , & github.Repository {
769+ Archived : github .Ptr (archived ),
770+ })
771+ if err != nil {
772+ return diag .FromErr (err )
773+ }
774+ d .SetId (repo .GetName ())
775+ return resourceGithubRepositoryRead (ctx , d , meta )
776+ }
777+
759778 topics := repoReq .Topics
760779 if len (topics ) > 0 {
761780 _ , _ , err := client .Repositories .ReplaceAllTopics (ctx , owner , repoName , topics )
0 commit comments