Skip to content

Commit

Permalink
Merge pull request #40 from gruntwork-io/v2
Browse files Browse the repository at this point in the history
Promotion Workflows V2
  • Loading branch information
ZachGoldberg authored Jul 9, 2024
2 parents 7681423 + 89c9410 commit 4ed18da
Show file tree
Hide file tree
Showing 21 changed files with 545 additions and 11,125 deletions.
61 changes: 49 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: yarn
- name: Run tests
run: yarn test
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -31,6 +19,7 @@ jobs:
run: yarn
- name: Run tests
run: yarn lint

check-dist:
runs-on: ubuntu-latest
steps:
Expand All @@ -50,3 +39,51 @@ jobs:
git diff
exit 1
fi
patcher-report-dev:
runs-on: ubuntu-latest
outputs:
spec: ${{ steps.run-report.outputs.spec }}
steps:
- uses: actions/checkout@v4
- name: Patcher
id: run-report
uses: ./
with:
github_token: ${{ secrets.CI_READONLY_READ_TOKEN }}
patcher_command: report
working_dir: infrastructure-live
spec_file: spec.json
include_dirs: "{*dev*}/**"
- uses: actions/upload-artifact@v4
with:
name: spec-file
path: spec.json

patcher-update-dev:
# Runs patcher update against each dependency for the specified accounts in dry run mode.
needs: [patcher-report-dev]
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
include: ${{ fromJson(needs.patcher-report-dev.outputs.spec).Dependencies }}
steps:
- uses: actions/checkout@v4
- name: Load spec file
uses: actions/download-artifact@v4
with:
name: spec-file
- name: Patcher
id: run-update
uses: ./
with:
github_token: ${{ secrets.CI_READONLY_READ_TOKEN }}
patcher_command: update
working_dir: infrastructure-live
spec_file: spec.json
pull_request_title: "[Patcher] [dev] Update ${{ matrix.ID }}"
pull_request_branch: "patcher-dev-updates-${{ matrix.ID }}"
dependency: ${{ matrix.ID }}
dry_run: true
24 changes: 20 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
patcher-report:
runs-on: ubuntu-latest
outputs:
dependencies: ${{ steps.run-report.outputs.dependencies }}
spec: ${{ steps.run-report.outputs.spec }}
steps:
- uses: actions/checkout@v4
- name: Patcher
Expand All @@ -19,19 +19,35 @@ jobs:
github_token: ${{ secrets.CI_READONLY_READ_TOKEN }}
patcher_command: report
working_dir: infrastructure-live
spec_file: spec.json
- uses: actions/upload-artifact@v4
with:
name: spec-file
path: spec.json

patcher-update:
# Runs patcher update against each dependency in the spec file
needs: [patcher-report]
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 2
matrix:
dependency: ${{ fromJson(needs.patcher-report.outputs.dependencies) }}
include: ${{ fromJson(needs.patcher-report.outputs.spec).Dependencies }}
steps:
- uses: actions/checkout@v4
- name: Load spec file
uses: actions/download-artifact@v4
with:
name: spec-file
- name: Patcher
id: run-update
uses: ./
with:
patcher_command: update
github_token: ${{ secrets.CI_READONLY_READ_TOKEN }}
dependency: ${{ matrix.dependency }}
patcher_command: update
working_dir: infrastructure-live
spec_file: spec.json
pull_request_title: "[Patcher] Update ${{ matrix.ID }}"
pull_request_branch: "patcher-updates-${{ matrix.ID }}"
dependency: ${{ matrix.ID }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### Intellij ###
.idea/
.vscode

### Node ###
# Logs
Expand Down
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf"
}
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@ steps:
### Action inputs
| Name | Description | Default |
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `github_token` | GitHub's Personal Access Token (PAT). | `GITHUB_TOKEN` |
| `patcher_command` | Patcher command to run. Valid options: `update` or `report`. | `update` |
| `working_dir` | Directory where Patcher should run. If empty, it will run in the whole repo. | |
| `update_strategy` | Update strategy. Only used when running `update`. Valid options: `next-safe` or `next-breaking`. Refer to the ["Update Strategies" documentation](https://docs.gruntwork.io/patcher/update-strategies). | `next-breaking` |
| `dependency` | Target the update to a single dependency. Only used when running `update`. Format: `<org>/<repo>/<name>`. Example: `gruntwork-io/terraform-aws-service-catalog/services/ecs-module`. | |
| `commit_author` | Author of the Pull Request's commits in the format `Name <[email protected]>`. Only used when running `update`. The permissions to push the changes and to create the Pull Request are from 'github_token'. | `gruntwork-patcher-bot <[email protected]>` |
| Name | Description | Default |
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `github_token` | GitHub's Personal Access Token (PAT). | `GITHUB_TOKEN` |
| `patcher_command` | Patcher command to run. Valid options: `update` or `report`. | `update` |
| `working_dir` | Directory where Patcher should run. If empty, it will run in the whole repo. | |
| `update_strategy` | Update strategy. Only used when running `update`. Valid options: `next-safe` or `next-breaking`. Refer to the ["Update Strategies" documentation](https://docs.gruntwork.io/patcher/update-strategies). | `next-breaking` |
| `include_dirs` | List of directories to include using a double-star glob pattern. Only used when running `report`. | |
| `exclude_dirs` | List of directories to exclude using a double-star glob pattern. Only used when running `report`. | |
| `spec_file` | Default name of the upgrade specification file. This is used by Patcher to restrict an upgrade to certain dependencies. | `spec.json` |
| `dependency` | Limit the update to a single dependency. Only used when running `update`. Format: `<org>/<repo>/<name>`. Example: `gruntwork-io/terraform-aws-service-catalog/services/ecs-module`. | |
| `commit_author` | Author of the Pull Request's commits in the format `Name <[email protected]>`. Only used when running `update`. The permissions to push the changes and to create the Pull Request are from 'github_token'. | `gruntwork-patcher-bot <[email protected]>` |
| `pull_request_branch` | Branch to use when creating the Pull Request. Required when running `update`. | |
| `pull_request_title` | Title of the Pull Request. Only used when running `update`. | `[Patcher] Update dependencies` |
| `dry_run` | Simulate all operations using Patcher's dry-run mode. Useful for test workflows. Only used when running `update`. | `false` |
| `no_color` | Whether to disable color output. | `false` |

### Action outputs
- `dependencies`: Terraform and Terragrunt dependencies from the given directory. Only works for `report`.
- `spec`: All discovered dependencies from the given directory using any filters. Only works for `report`.
- `updateResult`: The result of the upgrade. Only works for `update`.

### Promotion Workflows

Expand Down
36 changes: 30 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,50 @@ inputs:
patcher_command:
description: "Patcher command to run. Valid options: 'update' or 'report'."
default: "update"
include_dirs:
description: >
"Include only directories matching the given double-star glob pattern. Only works for `report`."
"Example: `{*dev*}/**`"
default: ""
exclude_dirs:
description: >
"Exclude any directories matching the given double-star glob pattern. Only works for `report`."
"Example: `"{*alb*}/**"`"
default: ""
update_strategy:
description: "Update strategy. Only used when running 'update'. Defaults to 'next-breaking'."
default: "next-breaking"
spec_file:
description: "Default name of the upgrade specification."
default: "spec.json"
dependency:
description: >
"Target the update to a single dependency. Format: <org>/<repo>/<name>."
"Limit the update to a single dependency. Format: <org>/<repo>/<name>."
"Example: gruntwork-io/terraform-aws-service-catalog/services/ecs-module."
working_dir:
description: "Directory where Patcher should run. If empty, it will run in the whole repo."
commit_author:
description: >
"Author of the Pull Request's commits in the format 'Name <[email protected]>'. The permissions to push the changes
"and to create the Pull Request are from 'github_token'. Defaults to gruntwork-patcher."
default: 'gruntwork-patcher-bot <[email protected]>'
"and to create the Pull Request are from 'github_token'. Defaults to gruntwork-patcher-bot."
default: "gruntwork-patcher-bot <[email protected]>"
pull_request_branch:
description: "Branch where the Pull Request should be created. Required when 'update' is used."
default: ""
pull_request_title:
description: "Title of the Pull Request. Defaults to '[Patcher] Update dependencies'."
default: "[Patcher] Update dependencies"
dry_run:
description: "Simulate all operations using dry-run mode. Useful for test workflows. Defaults to false."
default: "false"
no_color:
description: "Disable color output. Defaults to false."
default: "false"

outputs:
dependencies:
description: "Terraform and Terragrunt dependencies from the given directory. Only works for 'report'."

runs:
using: 'node16'
main: 'dist/index.js'

using: "node20"
main: "dist/index.js"
Loading

0 comments on commit 4ed18da

Please sign in to comment.