-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
616 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: weekly |
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,16 @@ | ||
name: Invoke-Pester | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Pester tests | ||
shell: pwsh | ||
run: Invoke-Pester -Output Detailed |
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,43 @@ | ||
# File: .github/workflows/release-version.yaml | ||
name: Create versioned release | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
update-type: | ||
type: choice | ||
description: Which version you want to increment? Use major, minor or patch | ||
required: true | ||
default: patch | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
label: | ||
description: Add Labels. i.e final, alpha, rc | ||
required: false | ||
pre-release: | ||
type: boolean | ||
description: Pre-release | ||
required: false | ||
default: false | ||
|
||
jobs: | ||
release-version: | ||
name: Create SemVer releases | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create version releases | ||
uses: climpr/semver-release@v1 | ||
with: | ||
update-type: ${{ github.event.inputs.update-type }} | ||
label: ${{ github.event.inputs.label }} | ||
pre-release: ${{ github.event.inputs.pre-release }} |
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,201 @@ | ||
# Update Landing Zone Repository | ||
|
||
<!-- TOC --> | ||
|
||
- [Update Landing Zone Repository](#update-landing-zone-repository) | ||
- [How to use this action](#how-to-use-this-action) | ||
- [Prerequisites](#prerequisites) | ||
- [`repoSource` strategy (Preferred)](#reposource-strategy-preferred) | ||
- [`repoTemplate` strategy](#repotemplate-strategy) | ||
- [delete-files.json](#delete-filesjson) | ||
- [File schema](#file-schema) | ||
- [Generating file hashes](#generating-file-hashes) | ||
- [Example](#example) | ||
- [Parameters](#parameters) | ||
- [`landing-zone-path`](#landing-zone-path) | ||
- [`repo-sources-path`](#repo-sources-path) | ||
- [`github-token`](#github-token) | ||
- [Outputs](#outputs) | ||
- [`deleted-files`](#deleted-files) | ||
- [`deleted-directories`](#deleted-directories) | ||
|
||
<!-- /TOC --> | ||
|
||
This action updates files in Landing Zone Repositories. | ||
|
||
It can be used with two strategies: | ||
|
||
1. `repoSources` (Preferred) source directories. | ||
2. `repoTemplate` GitHub template repository. | ||
|
||
It will sync all files in the respective source to the target Landing Zone repository. | ||
In addition, it will delete any files located in an `delete-files.json` file containing file paths and file hashes. | ||
|
||
## How to use this action | ||
|
||
To use this action, implement the steps as shown below in your workflow. | ||
|
||
```yaml | ||
# ... | ||
permissions: read | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get GH Token | ||
id: gh-app-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ vars.GH_APP_ID }} | ||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | ||
owner: ${{ github.repository_owner }} | ||
|
||
- name: Update Landing Zone Repository | ||
uses: climpr/update-landing-zone-repository@v1 | ||
with: | ||
landing-zone-path: ${{ path-to-landing-zone-dir }} | ||
repo-sources-path: lz-management/repo-sources | ||
github-token: ${{ steps.gh-app-token.outputs.token }} | ||
# ... | ||
``` | ||
|
||
## Prerequisites | ||
|
||
- If the Landing Zone is configured to use the `repoSource` strategy, it requires the repository to be checked out first. | ||
- A GitHub token that has `Read and write` permissions `Contents` on the target Landing Zone repository. | ||
- A `delete-files.json` configuration file for specifying which files to delete. More on this file in a separate chapter. | ||
|
||
The target Landing Zone can be configured with either of the two strategies. The prerequisites for the strategies are as follows: | ||
|
||
### `repoSource` strategy (Preferred) | ||
|
||
- A `repo-sources` directory in the repository running this action. | ||
- A `source` subdirectory in the `repo-sources` directory corresponding to the `repoSources.source` property in the Landing Zone configuration file. | ||
- The named `source` directory must contain a `contents` subdirectory containing the source files to copy. | ||
- The named `source` directory must contain a `delete-files.json` file, specifying which files to delete. More on this file in a separate chapter. | ||
|
||
> [!TIP] | ||
> The `repo-sources` directory can contain multiple `source` subdirectories to support different repositories having different sources or versioning sources. | ||
The file structure must be as follows: | ||
|
||
``` | ||
../ | ||
repo-sources/ | ||
<source>/ | ||
delete-files.json | ||
contents/ | ||
...<source files> | ||
...<source files> | ||
<source2>/ | ||
delete-files.json | ||
contents/ | ||
... | ||
``` | ||
|
||
### `repoTemplate` strategy | ||
|
||
As opposed to the `repoSource` strategy, the `repoTemplate` | ||
|
||
- A GitHub repository corresponding to the `repoTemplate` property in the Landing Zone configuration file. | ||
- The GitHub template repository must be configured as a template repository in GitHub. | ||
- The GitHub repository must contain the source files for the update operation. | ||
- The GitHub repository must contain a `delete-files.json` file in the root directory. | ||
|
||
The file structure must be as follows: | ||
|
||
``` | ||
<Repository>/ | ||
delete-files.json | ||
...<source files> | ||
...<source files> | ||
``` | ||
|
||
## delete-files.json | ||
|
||
This action requires you to create a `delete-files.json` configuration file. | ||
As the target repositories will contain files that are not part of the source directories or repositories, we cannot know which files to delete without explicitly configuring them. | ||
The `delete-files.json` file is used to specify which files to delete and which files to skip. | ||
|
||
To create this file, start with an empty file and add the following content: | ||
|
||
```json | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/climpr/climpr-schemas/main/schemas/v1.0.0/lz-management/delete-files.json#" | ||
} | ||
``` | ||
|
||
This will ensure you have auto-complete and validation for the configuration file. | ||
|
||
### File schema | ||
|
||
An example file looks like this: | ||
|
||
> [!TIP] | ||
> You can use either the `hash` property for a single file hash, or `hashes` property for a list of file hashes. This can be useful if you want to support multiple versions of the same file. | ||
```jsonc | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/climpr/climpr-schemas/main/schemas/v1.0.0/lz-management/delete-files.json#", | ||
// A list of directory relative paths that should be excluded from processing. | ||
"directoriesToExclude": [ | ||
".git" // The '.git', 'delete-files.json' and 'delete-files.jsonc' directory and files are always excluded. | ||
], | ||
// A list of directory relative paths that should be deleted. | ||
"filesToDelete": [ | ||
{ | ||
"path": "string", // Relative path to file | ||
"hash": "3A888546831AE05A0EC1D040DE396262284E4B4FC0066A00D56016BF3955C90E" // File hash | ||
}, | ||
{ | ||
"path": "string", // Relative path to file | ||
"hashes": [ | ||
// List of file hashes | ||
"3A888546831AE05A0EC1D040DE396262284E4B4FC0066A00D56016BF3955C90E" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Generating file hashes | ||
|
||
Generating file hashes is done by using the `Get-FileHash` command in PowerShell. | ||
|
||
#### Example | ||
|
||
In this example, the file hash is the string under `Hash` below. | ||
|
||
```powershell | ||
Get-FileHash "./directory/file.txt" | ||
# Result | ||
# Algorithm Hash Path | ||
# --------- ---- ---- | ||
# SHA256 E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 <root-path>/directory/file.txt | ||
``` | ||
|
||
## Parameters | ||
|
||
### `landing-zone-path` | ||
|
||
(Required) Path to the Landing Zone directory. | ||
|
||
### `repo-sources-path` | ||
|
||
(Required) Path to the 'repo-sources' directory. | ||
|
||
### `github-token` | ||
|
||
(Required) The token for the GitHub app that is allowed to create and update repositories in the organization. | ||
|
||
## Outputs | ||
|
||
### `deleted-files` | ||
|
||
A JSON list of the deleted files relative to the 'path' input parameter. | ||
|
||
### `deleted-directories` | ||
|
||
A JSON list of the deleted directories relative to the 'path' input parameter. |
Oops, something went wrong.