@@ -18,6 +18,8 @@ import (
1818)
1919
2020const (
21+ ActionsOrg = "slsa-framework"
22+ ActionsRepo = "source-actions"
2123 workflowPath = ".github/workflows/compute_slsa_source.yaml"
2224 workflowSource = "git+https://github.com/slsa-"
2325
4648 permissions:
4749 contents: write # needed for storing the vsa in the repo.
4850 id-token: write # meeded to mint yokens for signing
49- uses: slsa-framework/source-actions /.github/workflows/compute_slsa_source.yml@main
51+ uses: %s/%s /.github/workflows/compute_slsa_source.yml@%s # %s
5052
5153`
5254)
@@ -87,12 +89,21 @@ func (b *Backend) CreateWorkflowPR(r *models.Repository, branches []*models.Bran
8789 return nil , err
8890 }
8991
92+ // Get the actions repo tag
93+ actionsTag , actionsHash , err := b .GetLatestActionsTag ()
94+ if err != nil {
95+ return nil , fmt .Errorf ("getting latest actions tag: %w" , err )
96+ }
97+
9098 // Populate the branches in the workflow template
9199 quotedBranchesList := []string {}
92100 for _ , b := range branches {
93101 quotedBranchesList = append (quotedBranchesList , fmt .Sprintf ("%q" , b .Name ))
94102 }
95- workflowYAML := fmt .Sprintf (workflowData , strings .Join (quotedBranchesList , ", " ))
103+ workflowYAML := fmt .Sprintf (
104+ workflowData , strings .Join (quotedBranchesList , ", " ),
105+ ActionsOrg , ActionsRepo , actionsHash , actionsTag ,
106+ )
96107
97108 // We need to determine if the user needs a fork
98109 hasPush , err := b .checkPushAccess (r )
@@ -351,3 +362,34 @@ func (b *Backend) ConfigureControls(r *models.Repository, branches []*models.Bra
351362 }
352363 return errors .Join (errs ... )
353364}
365+
366+ // GetLatestActionsTag queries GitHub and fetches the latest tag and digest
367+ // of the slsa-framework/source-actions repository.
368+ func (b * Backend ) GetLatestActionsTag () (tag , digest string , err error ) {
369+ client , err := b .authenticator .GetGitHubClient ()
370+ if err != nil {
371+ return "" , "" , fmt .Errorf ("getting GitHub client: %w" , err )
372+ }
373+
374+ // List tags from slsa-framework/source-actions
375+ tags , _ , err := client .Repositories .ListTags (
376+ context .Background (), ActionsOrg , ActionsRepo ,
377+ & github.ListOptions {
378+ Page : 1 ,
379+ PerPage : 1 ,
380+ },
381+ )
382+ if err != nil {
383+ return "" , "" , fmt .Errorf ("listing tags: %w" , err )
384+ }
385+
386+ if len (tags ) == 0 {
387+ return "" , "" , errors .New ("no tags found in slsa-framework/source-actions" )
388+ }
389+
390+ latestTag := tags [0 ]
391+ tagName := latestTag .GetName ()
392+ commitSHA := latestTag .GetCommit ().GetSHA ()
393+
394+ return tagName , commitSHA , nil
395+ }
0 commit comments