ionbazan / composer-diff-action Goto Github PK
View Code? Open in Web Editor NEWCompare composer.lock files and generate human-readable list of package changes
License: MIT License
Compare composer.lock files and generate human-readable list of package changes
License: MIT License
Got error message today:
In PackageDiff.php line 135:
Could not open file ad66625dce6fd04da4b628f870a7230cce53fd10:apps/silverbac
k-drupal/composer.lock or find it in git as ad66625dce6fd04da4b628f870a7230
cce53fd10:apps/silverback-drupal/composer.lock
I tried to debug it by adding a new job step:
git show ad66625dce6fd04da4b628f870a7230cce53fd10:apps/silverback-drupal/composer.lock
This one worked without any issues.
Debugging here: AmazeeLabs/silverback-mono#1021
I just started using this action but it never posts a comment, even when there is output in the diff (because the exit code is 0). I think the issue is that the README is newer than the most recent release so the code that runs in the action doesn't match the posted docs. The needed PR is #5
We have a project where the composer.lock file is situated in a subfolder (packages/backend/
).
I tried to set the target
parameter to configure this, but I can't seem to find the correct one.
This is the last one I tried:
name: Composer Diff
on:
pull_request:
paths:
- 'packages/backend/composer.lock'
jobs:
composer-diff:
name: Composer Diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to make it possible to compare with PR base branch
- name: Generate composer diff
id: composer_diff # To reference the output in comment
uses: IonBazan/composer-diff-action@v1
with:
target: ${{ github.event.pull_request.base.sha }}:packages/backend/composer.lock
- uses: marocchino/sticky-pull-request-comment@v2
# An empty diff result will break this action.
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
target: ${{ github.event.pull_request.base.sha }}:packages/backend/composer.lock
header: composer-diff # Creates a collapsed comment with the report
message: |
<details>
<summary>Composer package changes</summary>
${{ steps.composer_diff.outputs.composer_diff }}
</details>
In the "Generate composer diff" step we receive the error Could not open file 2a6af2d592e1f11b0d4e535bb096133d62096101 or find it in git as 2a6af2d592e1f11b0d4e535bb096133d62096101:composer.lock: fatal: path 'composer.lock' does not exist in '2a6af2d592e1f11b0d4e535bb096133d62096101
In the "Run marocchino/sticky-pull-request-comment@v2" step we receive the warning Unexpected input(s) 'target', valid inputs are ['header', 'append', 'recreate', 'delete', 'only_create', 'only_update', 'hide_details', 'hide', 'hide_and_recreate', 'hide_classify', 'message', 'path', 'ignore_empty', 'skip_unchanged', 'follow_symbolic_links', 'number', 'owner', 'repo', 'GITHUB_TOKEN']
.
These two errors tell me that the target keys in the config are at the wrong place. Could someone point us in the right direction here?
hi there!
You action works perfectly on my PR workflow, no problem there.
I'd like to commit a composer update on a schedule. here is my workflow:
'on':
schedule:
-
cron: '24 6 * * 1,2,3,4,5'
workflow_dispatch: null
jobs:
composer_update_job:
runs-on: ubuntu-latest
name: 'composer update'
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
-
name: 'Run composer update'
run: 'composer update --no-dev --no-progress'
id: run_composer
- name: Generate composer diff
id: composer_diff # To reference the output in comment
uses: IonBazan/composer-diff-action@v1
with:
no-dev: true
format: mdlist
-
name: 'Create Pull Request'
uses: peter-evans/create-pull-request@v4
id: cpr
with:
token: '${{ secrets.MERGE_TOKEN }}'
commit-message: ${{ steps.composer_diff.outputs.composer_diff }}
committer: 'Woogo Bot <[email protected]>'
author: 'Woogo Bot <[email protected]>'
branch: woogobot/composer-update
delete-branch: true
title: 'feat(plugins) composer update'
labels: 'composer update'
The output of ${{ steps.composer_diff.outputs.composer_diff }}
is empty there. However in the PR check, it will be correct.
What am I doing wrong here ?
Thanks!
When there is no changes to the lock file, an empty composer_diff
output is produced, but it's not truly empty.
See log of one oof my workflows:
##[debug]Evaluating: format('{0}
##[debug]', steps.composer_diff.outputs.composer_diff)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> '{0}
##[debug]'
##[debug]..Evaluating Index:
##[debug]....Evaluating Index:
##[debug]......Evaluating Index:
##[debug]........Evaluating steps:
##[debug]........=> Object
##[debug]........Evaluating String:
##[debug]........=> 'composer_diff'
##[debug]......=> Object
##[debug]......Evaluating String:
##[debug]......=> 'outputs'
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'composer_diff'
##[debug]..=> ''
##[debug]=> '
##[debug]'
##[debug]Result: '
##[debug]'
then marocchino/sticky-pull-request-comment@v2
fails with Error: Either message or path input is required
, but I cannot check if the output is an empty string like ''
and skip the step, because it's not an empty string
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.