forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph-update.yml
More file actions
65 lines (56 loc) 路 2.07 KB
/
Copy pathgraph-update.yml
File metadata and controls
65 lines (56 loc) 路 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Terraform Graph Update
on:
pull_request:
paths:
- "infrastructure/terraform/**"
push:
branches: [main]
paths:
- "infrastructure/terraform/**"
permissions:
contents: write
pull-requests: write
jobs:
graph:
name: Generate Graph
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.7.5"
- name: Install graphviz
run: sudo apt-get update && sudo apt-get install -y graphviz
- name: Generate Terraform graph
run: |
bash infrastructure/scripts/generate-tf-graph.sh
- name: Upload graph artifacts
uses: actions/upload-artifact@v4
with:
name: terraform-graph
path: |
infrastructure/docs/resource-graph.svg
infrastructure/docs/resource-graph.html
retention-days: 30
- name: Comment graph on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const svg = fs.readFileSync('infrastructure/docs/resource-graph.svg', 'utf8');
const truncated = svg.length > 60000 ? svg.slice(0, 60000) + '\n<!-- truncated -->' : svg;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Terraform Resource Graph\n\n\n\nSee artifact for full interactive HTML view.`,
});
- name: Commit updated graph
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
git config user.name "github-actions"
git config user.email "actions@github.com"
git add infrastructure/docs/resource-graph.svg infrastructure/docs/resource-graph.html
git diff --cached --quiet || git commit -m "chore: update Terraform resource graph [skip ci]"
git push