Skip to content

AXP-158: Dependency diff #10

AXP-158: Dependency diff

AXP-158: Dependency diff #10

name: Dependency Diff
on:
pull_request:
types:
- opened
- synchronize
permissions:
pull-requests: write
contents: read
jobs:
dependency-diff:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
composer.lock
web/themes/custom/contribtracker/package-lock.json
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- name: Set up PHP
if: contains(steps.changed-files.outputs.modified_files, 'composer.lock')
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
- name: Install composer-lock-diff and run
if: contains(steps.changed-files.outputs.modified_files, 'composer.lock')
run: |
composer global require davidrjonas/composer-lock-diff:^1.0
composer-lock-diff --from=${{ github.event.pull_request.base.sha }} --md > dependency-diff.md
# output in json format for fetching release notes
composer-lock-diff --from=${{ github.event.pull_request.base.sha }} --json > composer-diff.json
- name: NPM Diff
if: contains(steps.changed-files.outputs.modified_files, 'web/themes/custom/contribtracker/package-lock.json')
run: |
npm install -g diff-lockfiles
echo '**NPM Package changes**' >> dependency-diff.md
echo '```' >> dependency-diff.md
diff-lockfiles ${{ github.event.pull_request.base.sha }} HEAD --shallow >> dependency-diff.md
echo '```' >> dependency-diff.md
- name: Fetch Release notes
uses: actions/github-script@v7
with:
script: |
const fetchReleaseNotes = require('${{ github.workspace }}/.github/workflows/release-notes/fetch-data.js')
const release_notes = await fetchReleaseNotes()
require('fs').appendFileSync('${{ github.workspace }}/dependency-diff.md', release_notes);
- name: Add PR comment
if: steps.changed-files.outputs.any_modified == 'true'
uses: mshick/add-pr-comment@v2
with:
message-id: dependency-diff
message-path: dependency-diff.md