This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
add template engine functionality to support generic templates #262
Merged
Merged
Changes from 45 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
526400f
move config*.json files to configs directory
galargh f727003
rename configs/*.json
galargh f434f15
make checks aware of all the configs/*.json
galargh 496348f
turn configs into objects with repositories key
galargh 67da4b2
make files part of the config
galargh b9aaa52
move language specific copy-workflow setup to actions
galargh 02436cf
make dispatch workflow support more than one config json
galargh 0d71b9e
create fewer batches if possible
galargh 0828267
set up copy-workflow actions properly
galargh 1dfeb94
extract defaults from config separately
galargh 16e4ca8
bring back double toJson
galargh dbe2f9c
use copy-workflow actions from same branch
galargh f5cf5ab
use compact json representation for storing FILES
galargh 6955318
fix files and local actions
galargh c95cbff
run actions from template repo
galargh 5c86ae0
add missing shell property to actions
galargh 0b3c5cb
add configs README
galargh 07f9202
set deploy_versioning=true for go repositories
galargh 9fdc4eb
address review comments
galargh 60d1f29
restore hardcoded template-repo reference
galargh a71f87a
add section on config testing
galargh 0f34080
fix batches creation
galargh b2c1dd9
fix command that produces batches
galargh 664f8b7
fix needs update logic
galargh d54c585
add template and reusable workflow for sync-release-assets
galargh 756a68c
do not include the entire config in copied file
galargh 557dd05
escape { in regexp pattern so that Actions don't interpret it
galargh 95fc5c8
fix context variable setup
galargh 1dcd301
escape slashes
galargh 6d14255
echo context instead of input redirect
galargh 8696afd
use backticks instead of qx syntax
galargh b708708
remove repo object from github context
galargh ba2b680
add templates README
galargh d44d862
fix inputs usage in sync-release-assets workflow
galargh 359f6a5
simplify dist config
galargh 1100c54
add all fields that might appear in config context
galargh 9706e9c
escape single quotes when executing bash from perl
galargh 486f183
add comments explaining the perl script
galargh 0f14645
trust workflows published in ipfs org
galargh 0ee771b
Merge remote-tracking branch 'origin/master' into sync-release-assets
galargh 5ddc3be
move go-ipfs config from go.json to custom.json
galargh 406b183
Update templates/README.md
galargh 676e490
describe how context container is created
galargh 2fbe6c8
Merge remote-tracking branch 'origin/master' into sync-release-assets
galargh 01192c5
Revert: creation of sync-release-assets.yml workflow
galargh d72d162
Merge remote-tracking branch 'origin/master' into sync-release-assets
galargh 62f9128
chore: apply review requests
galargh ddb2ba2
chore: simplify template engine and update js workflow
galargh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Templates | ||
|
||
This directory contains template files that can be expanded and copied over to the configured repositories. | ||
|
||
## Header | ||
|
||
The [header](header.yml) is prepended to all the files before they are copied to the target repositories. | ||
|
||
## Contexts | ||
|
||
You can access context information during template expansion (before copy is performed). | ||
|
||
### About contexts | ||
|
||
Contexts are a way to access information about the repository configuration object and repository GitHub settings. Contexts use the following syntax: | ||
|
||
``` | ||
${{{ <context> }}} | ||
``` | ||
|
||
| Context name | Type | Description | | ||
| --- | --- | --- | | ||
| `config` | `object` | Configuration object because of which the file is being copied. For more information, see [config context](#config-context) | | ||
| `github` | `object` | Information about the target repository the file is being copied to. For more information, see [github context](#github-context) | | ||
|
||
The context container is generated automatically before template expansion is performed. | ||
|
||
#### `config` context | ||
|
||
The `config` context is the configuration object because of which the file is being copied. It is created by merging the `defaults` object with a `repository` object (from the `repositories` array) from a JSON configuration file. | ||
|
||
| Property name | Type | Always present | Description | | ||
| --- | --- | --- | --- | | ||
| `config` | `object` | `true` | The top-level context. | true | | ||
| `config.files` | `array` | `true` | The files that are being copied. | | ||
| `config.extra_files` | `array` | `false` | The additional files that are also being copied. | | ||
| `config.target` | `string` | `true` | The name of the target repository in `{owner}/{repo}` format. | | ||
| `config.deploy_go` | `boolean` | `false` | Flag controling if Go specific setup should be applied to the repository. | | ||
| `config.deploy_versioning` | `boolean` | `false` | Flag controling if `versions.json` file should be deployed to the repository. | | ||
| `config.dist` | `string` | `false` | The name of the distribution built from the repository. | | ||
|
||
#### `github` context | ||
|
||
The `github` context contains information about the target repository the file is being copied to. It is created on the fly before template expansion is performed. | ||
|
||
| Property name | Type | Always present | Description | | ||
| --- | --- | --- | --- | | ||
| `github` | `object` | `true` | The top-level context. | | ||
| `github.default_branch` | `string` | `true` | The name of the default branch of the target repository. | | ||
|
||
### Examples | ||
|
||
#### JSON configuration | ||
|
||
```json | ||
{ | ||
"defaults": { | ||
"files": [".github/workflows/automerge.yml"], | ||
"is_example": false | ||
}, | ||
"repositories": [ | ||
{ | ||
"target": "protocol/.github-test-target", | ||
"extra_files": [".github/workflows/example.yml"], | ||
"example": { | ||
"greeting": "Hello" | ||
}, | ||
"is_example": true | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### Context container | ||
|
||
*created automatically before template expansion is performed* | ||
|
||
```json | ||
{ | ||
"config": { | ||
"target": "protocol/.github-test-target", | ||
"files": [".github/workflows/automerge.yml"], | ||
"extra_files": [".github/workflows/example.yml"], | ||
"example": { | ||
"greeting": "Hello" | ||
}, | ||
"is_example": true | ||
}, | ||
"github": { | ||
"default_branch": "master" | ||
} | ||
} | ||
``` | ||
|
||
#### Template | ||
|
||
```yaml | ||
name: Hello | ||
on: | ||
push: | ||
branches: | ||
- ${{{ github.default_branch }}} | ||
jobs: | ||
echo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo ${{{ config.example.greeting }}} | ||
shell: bash | ||
``` | ||
|
||
#### Expanded template | ||
|
||
```yaml | ||
name: Hello | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
echo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo Hello | ||
shell: bash | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://xkcd.com/1171/