|
| 1 | +name: Update Dockerfile Dependency Graph |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'Dockerfile' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - 'Dockerfile' |
| 10 | + |
| 11 | +jobs: |
| 12 | + update-graph: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Store old image hash if exists |
| 24 | + id: old_hash |
| 25 | + run: | |
| 26 | + if [ -f "docs/source/assets/contributing/dockerfile-stages-dependency.png" ]; then |
| 27 | + sha256sum docs/source/assets/contributing/dockerfile-stages-dependency.png > old_hash.txt |
| 28 | + fi |
| 29 | +
|
| 30 | + - name: Ensure target directory exists |
| 31 | + run: mkdir -p docs/source/assets/contributing |
| 32 | + |
| 33 | + - name: Generate Dockerfile graph |
| 34 | + run: | |
| 35 | + docker run \ |
| 36 | + --rm \ |
| 37 | + --user "$(id -u):$(id -g)" \ |
| 38 | + --workdir /workspace \ |
| 39 | + --volume "$(pwd)":/workspace \ |
| 40 | + ghcr.io/patrickhoefler/dockerfilegraph:alpine \ |
| 41 | + --output png \ |
| 42 | + --dpi 200 \ |
| 43 | + --max-label-length 50 \ |
| 44 | + --filename Dockerfile \ |
| 45 | + --legend |
| 46 | + mv Dockerfile.png docs/source/assets/contributing/dockerfile-stages-dependency.png |
| 47 | +
|
| 48 | + - name: Check for changes |
| 49 | + id: check_changes |
| 50 | + run: | |
| 51 | + if [ -f "old_hash.txt" ]; then |
| 52 | + NEW_HASH="$(sha256sum "docs/source/assets/contributing/dockerfile-stages-dependency.png")" |
| 53 | + OLD_HASH="$(cat "old_hash.txt")" |
| 54 | + if [ "$NEW_HASH" != "$OLD_HASH" ]; then |
| 55 | + echo "changes_detected=true" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Graph has changed." |
| 57 | + else |
| 58 | + echo "changes_detected=false" >> "$GITHUB_OUTPUT" |
| 59 | + echo "No changes in graph." |
| 60 | + fi |
| 61 | + else |
| 62 | + echo "changes_detected=true" >> "$GITHUB_OUTPUT" |
| 63 | + echo "First time generating graph." |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Create Pull Request |
| 67 | + if: steps.check_changes.outputs.changes_detected == 'true' |
| 68 | + uses: peter-evans/create-pull-request@v6 |
| 69 | + with: |
| 70 | + commit-message: "docs: update Dockerfile dependency graph" |
| 71 | + title: "docs: update Dockerfile dependency graph" |
| 72 | + body: | |
| 73 | + This PR updates the Dockerfile dependency graph following changes to the Dockerfile. |
| 74 | + |
| 75 | + - Generated by GitHub Actions |
| 76 | + - Updates visualization in docs/source/assets/contributing/ |
| 77 | + branch: update-dockerfile-graph |
| 78 | + delete-branch: true |
| 79 | + base: main |
0 commit comments