Parse permissions (#133)
Resurrecting [this PR](https://gitea.com/gitea/act/pulls/73) as the original author has [lost motivation](https://github.com/go-gitea/gitea/pull/25664#issuecomment-2737099259) (though, to be clear - all credit belongs to them, all mistakes are mine and mine alone!) Co-authored-by: Søren L. Hansen <sorenisanerd@gmail.com> Reviewed-on: https://gitea.com/gitea/act/pulls/133 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Jack Jackson <scubbojj@gmail.com> Co-committed-by: Jack Jackson <scubbojj@gmail.com>
This commit is contained in:
@@ -60,10 +60,11 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
|||||||
}
|
}
|
||||||
job.RawRunsOn = encodeRunsOn(runsOn)
|
job.RawRunsOn = encodeRunsOn(runsOn)
|
||||||
swf := &SingleWorkflow{
|
swf := &SingleWorkflow{
|
||||||
Name: workflow.Name,
|
Name: workflow.Name,
|
||||||
RawOn: workflow.RawOn,
|
RawOn: workflow.RawOn,
|
||||||
Env: workflow.Env,
|
Env: workflow.Env,
|
||||||
Defaults: workflow.Defaults,
|
Defaults: workflow.Defaults,
|
||||||
|
RawPermissions: workflow.RawPermissions,
|
||||||
}
|
}
|
||||||
if err := swf.SetJob(id, job); err != nil {
|
if err := swf.SetJob(id, job); err != nil {
|
||||||
return nil, fmt.Errorf("SetJob: %w", err)
|
return nil, fmt.Errorf("SetJob: %w", err)
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ import (
|
|||||||
|
|
||||||
// SingleWorkflow is a workflow with single job and single matrix
|
// SingleWorkflow is a workflow with single job and single matrix
|
||||||
type SingleWorkflow struct {
|
type SingleWorkflow struct {
|
||||||
Name string `yaml:"name,omitempty"`
|
Name string `yaml:"name,omitempty"`
|
||||||
RawOn yaml.Node `yaml:"on,omitempty"`
|
RawOn yaml.Node `yaml:"on,omitempty"`
|
||||||
Env map[string]string `yaml:"env,omitempty"`
|
Env map[string]string `yaml:"env,omitempty"`
|
||||||
RawJobs yaml.Node `yaml:"jobs,omitempty"`
|
RawJobs yaml.Node `yaml:"jobs,omitempty"`
|
||||||
Defaults Defaults `yaml:"defaults,omitempty"`
|
Defaults Defaults `yaml:"defaults,omitempty"`
|
||||||
|
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SingleWorkflow) Job() (string, *Job) {
|
func (w *SingleWorkflow) Job() (string, *Job) {
|
||||||
@@ -84,6 +85,7 @@ type Job struct {
|
|||||||
With map[string]interface{} `yaml:"with,omitempty"`
|
With map[string]interface{} `yaml:"with,omitempty"`
|
||||||
RawSecrets yaml.Node `yaml:"secrets,omitempty"`
|
RawSecrets yaml.Node `yaml:"secrets,omitempty"`
|
||||||
RawConcurrency *model.RawConcurrency `yaml:"concurrency,omitempty"`
|
RawConcurrency *model.RawConcurrency `yaml:"concurrency,omitempty"`
|
||||||
|
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) Clone() *Job {
|
func (j *Job) Clone() *Job {
|
||||||
@@ -107,6 +109,7 @@ func (j *Job) Clone() *Job {
|
|||||||
With: j.With,
|
With: j.With,
|
||||||
RawSecrets: j.RawSecrets,
|
RawSecrets: j.RawSecrets,
|
||||||
RawConcurrency: j.RawConcurrency,
|
RawConcurrency: j.RawConcurrency,
|
||||||
|
RawPermissions: j.RawPermissions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ import (
|
|||||||
|
|
||||||
// Workflow is the structure of the files in .github/workflows
|
// Workflow is the structure of the files in .github/workflows
|
||||||
type Workflow struct {
|
type Workflow struct {
|
||||||
File string
|
File string
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
RawOn yaml.Node `yaml:"on"`
|
RawOn yaml.Node `yaml:"on"`
|
||||||
Env map[string]string `yaml:"env"`
|
Env map[string]string `yaml:"env"`
|
||||||
Jobs map[string]*Job `yaml:"jobs"`
|
Jobs map[string]*Job `yaml:"jobs"`
|
||||||
Defaults Defaults `yaml:"defaults"`
|
Defaults Defaults `yaml:"defaults"`
|
||||||
|
RawConcurrency *RawConcurrency `yaml:"concurrency"`
|
||||||
RawConcurrency *RawConcurrency `yaml:"concurrency"` // For Gitea
|
RawPermissions yaml.Node `yaml:"permissions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// On events for the workflow
|
// On events for the workflow
|
||||||
@@ -201,6 +201,7 @@ type Job struct {
|
|||||||
Uses string `yaml:"uses"`
|
Uses string `yaml:"uses"`
|
||||||
With map[string]interface{} `yaml:"with"`
|
With map[string]interface{} `yaml:"with"`
|
||||||
RawSecrets yaml.Node `yaml:"secrets"`
|
RawSecrets yaml.Node `yaml:"secrets"`
|
||||||
|
RawPermissions yaml.Node `yaml:"permissions"`
|
||||||
Result string
|
Result string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user