Skip to content

dyff of rendered templates - comment #1666

dyff of rendered templates - comment

dyff of rendered templates - comment #1666

# Copyright 2025 New Vector Ltd
# Copyright 2025-2026 Element Creations Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
name: dyff of rendered templates - comment
on:
workflow_run: # zizmor: ignore[dangerous-triggers] This is safe as not running any shell scripts, nor using any code from the upstream workflow
workflows: ["dyff of rendered templates"]
types:
- completed
permissions:
actions: read
pull-requests: write
jobs:
manage-comment:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download dyff of templates
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
name: dyff-templates
run-id: ${{ github.event.workflow_run.id }}
# We cannot get the outputs from the worfklow run, so we have to download the artifact and parse the PR Number from there
- name: Load PR number
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
id: pr-number
with:
script: |
const fs = require('fs');
const prNumberOut = fs.readFileSync('pr-number.txt', 'utf8').trim();
const prNumber = Number(prNumberOut);
// Check if the conversion is valid and the number is a positive integer
if (isNaN(prNumber) || prNumber < 1 || !Number.isInteger(prNumber)) {
throw new Error(`Invalid PR number: ${prNumber}. Expected a positive integer.`);
}
core.setOutput('pr-number', prNumber);
- name: Find dyff comment
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: find-dyff-comment
with:
issue-number: ${{ steps.pr-number.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: 'dyff of changes in rendered templates'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.find-dyff-comment.outputs.comment-id }}
issue-number: ${{ steps.pr-number.outputs.pr-number }}
body-path: dyff-output.md
edit-mode: replace