composer-lock-diff
composer-lock-diff copied to clipboard
Example Action
This tool is brilliant.
I was wondering if it has been integrated with Github actions, it would seem like a sensible thing to do and I'm happy to look at getting something together for it but it would seem that somebody else would have done this already.
That's a great idea. I've never used github actions so it may take me some time to get to it. If you have time to add a github action I'd be more than happy to make any changes required and/or include it here.
+1 to this idea. This could be taken even further now by providing a GitHub Marketplace action: https://github.com/marketplace?type=actions
Then adding this to a project would be as simple as adding the action to any project through the GitHub UI, without needing to configure permissions and set up keys for posting comments.
I have this working but not in a way that can be put into Marketplace just yet
name: Composer lock diff
on:
pull_request:
paths:
- 'composer.lock'
defaults:
run:
shell: bash
working-directory: difftest
jobs:
full:
name: Composer lock diff.
runs-on: ubuntu-18.04
env:
CI: GITHUB_ACTIONS
steps:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
coverage: none # Disable xDebug
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: checkout
uses: actions/checkout@v2
with:
ref: trunk
path: 'difftest'
fetch-depth: 0
- name: install lock diff diff
run: composer global require davidrjonas/composer-lock-diff:^1.0
- name: run lock diff
run: |
echo "### Composer lock diff \n\n" > composer_diff.md
~/.composer/vendor/bin/composer-lock-diff --to ${{ github.event.pull_request.head.sha }} --md | sed -z 's/\n/\\n/g' >> composer_diff.md
echo "\n\n" >> composer_diff.md
echo '{ "body" : "'`cat composer_diff.md`'"}' > composer_diff.json
cat composer_diff.json
- name: Add comment to PR
run: |
curl \
-X POST \
${{ github.event.pull_request.comments_url }} \
-H "Accept: application/vnd.github.v3.raw+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--data '@composer_diff.json'