Skip to content

Generate AWS DaC Diagrams #4

Generate AWS DaC Diagrams

Generate AWS DaC Diagrams #4

name: Generate AWS DaC Diagrams
on:
workflow_dispatch:
jobs:
generate-diagram:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
CI_COMMIT_MESSAGE: Update generated diagram
CI_COMMIT_AUTHOR: Diagram Creator
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Git Global Config
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "actions@github.com"
- name: Set up Go environment
uses: actions/setup-go@v4
with:
go-version: '1.21' # AWSDAC requires Go 1.21 or higher
- name: Install awsdac CLI tool
run: |
go install github.com/awslabs/diagram-as-code/cmd/awsdac@latest
- name: Generate diagram from YAML
run: |
# Generate current date and time & Create Directory
timestamp=$(date +"%Y-%m-%d-%H-%M-%S")
mkdir -p output/aws-diagram-as-code/
# Run the awsdac tool to generate a diagram from the YAML file
$HOME/go/bin/awsdac setup/aws-diagram-as-code.yaml -o output/aws-diagram-as-code/generated-diagram-$timestamp.png
- name: List generated files (for debugging)
run: ls -al output/aws-diagram-as-code/
- name: Add output files & Status
run: |
git add output/
git status
- name: Commit changes & Push to origin/main
run: |
git commit --verbose -a -m "${{ env.CI_COMMIT_MESSAGE }}" || echo "No changes to commit"
git push origin main --force --verbose
- name: Push changes
uses: ad-m/github-push-action@master
with:
force: true
ref: ${{ github.head_ref }}
fetch-depth: 0