-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
427084f
commit 7879ac2
Showing
4 changed files
with
147 additions
and
1 deletion.
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,30 @@ | ||
name: Update Main Version | ||
run-name: Move ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.target }} | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
target: | ||
description: The tag or reference to use | ||
required: true | ||
major_version: | ||
type: choice | ||
description: The major version to update | ||
options: | ||
- v1 | ||
|
||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Git config | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Tag new target | ||
run: git tag -f ${{ github.event.inputs.major_version }} ${{ github.event.inputs.target }} | ||
- name: Push new tag | ||
run: git push origin ${{ github.event.inputs.major_version }} --force |
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,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"structurizr" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,2 +1,64 @@ | ||
# structutizr-gh-action-gen-images | ||
# Generate Structurizr Diagrams Action | ||
|
||
## Introduction | ||
|
||
This GitHub Action automatically generates and updates Structurizr diagrams on pull requests. It's designed to simplify the process of keeping architecture diagrams up-to-date with the latest changes in your codebase. | ||
|
||
## Prerequisites | ||
|
||
Before you use this action, make sure you have: | ||
|
||
- A GitHub repository. | ||
- A `workspace.dsl` file in your repository for Structurizr. | ||
|
||
## Usage | ||
|
||
To use this action in your workflow, follow these steps: | ||
|
||
1. **Set up the workflow**: Create a `.github/workflows` directory in your repository if it doesn't exist. | ||
2. **Create a workflow file**: Inside the `.github/workflows` directory, create a new file (e.g., `structurizr-diagrams-update.yml`) and add the following content: | ||
|
||
```yaml | ||
name: Update Structurizr Diagrams | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'docs/workspace.dsl' # This setting will have the action trigger only if certain file changes. Set the location of your DSL. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
update-diagrams: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: sebastienfi/structurizr-gen-images@v1 | ||
with: | ||
workspace-path: 'docs/workspace.dsl' # This setting will have the action generate images from this DSL. Set the location of your DSL. | ||
``` | ||
3. Commit the workflow to `main` and create a PR which include a change in your DSL file. | ||
4. The action will commit the generated images to your Pr's branch. | ||
|
||
## Inputs | ||
|
||
This action accepts the following inputs: | ||
|
||
- `workspace-path`: Path to the `workspace.dsl` file. | ||
- **Required**: Yes | ||
- **Default**: `docs/workspace.dsl` | ||
|
||
## Outputs | ||
|
||
This action does not produces any output. | ||
|
||
## Additional Notes | ||
|
||
- Ensure that the `workspace.dsl` file is correctly set up and located in the specified path. | ||
- The action will check for changes in the diagram images and update them if necessary. | ||
- Generated diagrams are committed and pushed to the same branch that initiated the pull request. Of course, if your diagram does not change, there will be no commit. | ||
|
||
## Contributing | ||
|
||
Contributions to this action are welcome. Please ensure that your pull requests are well-described and adhere to the project's coding standards. |
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,49 @@ | ||
name: 'Generate Structurizr Diagrams' | ||
description: 'Automatically generates and updates Structurizr diagrams on pull requests.' | ||
inputs: | ||
# You can define inputs that users of your action can specify | ||
# For example, the path to workspace.dsl if it varies | ||
workspace-path: | ||
description: 'Path to the workspace.dsl file' | ||
required: true | ||
default: 'docs/workspace.dsl' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup Git | ||
run: git config --global --add safe.directory $PWD | ||
shell: bash | ||
|
||
- name: Generate Diagram Images | ||
run: | | ||
output_dir="docs/diagrams" # Default output directory | ||
/usr/local/structurizr-cli/structurizr.sh export -workspace ${{ inputs.workspace-path }} -format plantuml -output $output_dir | ||
cd $output_dir | ||
echo 'Generating PNGs...' | ||
plantuml -tpng *.puml | ||
shell: bash | ||
|
||
- name: Check for Changes | ||
id: check_changes | ||
run: | | ||
git add *.png | ||
if git diff --staged --quiet; then | ||
echo "CHANGES_EXIST=false" >> $GITHUB_ENV | ||
else | ||
echo "CHANGES_EXIST=true" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Commit and Push Diagrams | ||
if: env.CHANGES_EXIST == 'true' | ||
run: | | ||
git commit -m "chores(C4 diagrams): Update Structurizr diagrams for views" | ||
git push origin HEAD:${GITHUB_HEAD_REF} | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |