-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathgenerate-action.pkl
More file actions
62 lines (56 loc) · 2.41 KB
/
generate-action.pkl
File metadata and controls
62 lines (56 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//===----------------------------------------------------------------------===//
// Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
/// Generates a typed step that calls out to a GitHub Action.
///
/// The types for an action can be enhanced with types from typesafegithub.
/// It will look either at the repo's `action-types.yml` file, or within
/// [github-actions-typing-catalog](https://github.com/typesafegithub/github-actions-typing-catalog)
/// to determine the corresponding types.
///
/// If actions are missing in either of these sources, use the programmatic [ActionGenerator] instead.
///
/// Sample usage:
///
/// pkl eval package://pkg.pkl-lang.org/pkl-pantry/com.github.actions.contrib@<VERSION>#/generate-action.pkl \
/// -m . \
/// -p action-name=actions/checkout@v4
///
/// Optionally, you can specify a different GitHub Actions package with the `action-package-name` parameter
@ModuleInfo { minPklVersion = "0.30.0" }
module com.github.actions.contrib.`generate-action`
import "ActionGenerator.pkl"
/// The name of the action that should be generated.
///
/// Should include the version string.
actionName: ActionGenerator.ActionName = read("prop:action-name")
/// Optional override of the GitHub actions package.
githubActionsPackageName: String? = read?("prop:action-package-name")
local generator: ActionGenerator = new {
actionName = module.actionName
when (module.githubActionsPackageName != null) {
githubActionsPackageName = module.githubActionsPackageName
}
}
fixed files: Mapping<String, FileOutput> = new {
// noinspection TypeMismatch
["\(generator.modulePath.join("/"))/\(generator.moduleName).pkl"] {
text = generator.result
}
}
output {
text = throw("I must be called using the `-m` flag.")
files = module.files
}