-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ComposerLockDiff workflow to run without DDEV and use a sticky pull request comment #538
Changes from all commits
5a7f642
f49cd63
a256f1b
7fcc0c1
5c9a084
4d4433a
f848a2d
52b4582
f2c8724
57d94dd
e273b0e
6ab1ccc
5f9f36a
344933b
4b3407f
fbfe18d
d436532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,46 +17,33 @@ jobs: | |||||||||||
steps: | ||||||||||||
- uses: actions/checkout@v4 | ||||||||||||
with: | ||||||||||||
fetch-depth: 2 | ||||||||||||
fetch-depth: 0 | ||||||||||||
|
||||||||||||
- uses: actions/cache@v4 | ||||||||||||
- name: Check if composer.lock was changed | ||||||||||||
id: composer-lock-changed | ||||||||||||
uses: tj-actions/changed-files@v44 | ||||||||||||
with: | ||||||||||||
path: ${{ github.workspace }}/.ddev/.drainpipe-composer-cache | ||||||||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||||||||||||
restore-keys: | | ||||||||||||
${{ runner.os }}-composer- | ||||||||||||
files: 'composer.lock' | ||||||||||||
|
||||||||||||
- uses: ./.github/actions/drainpipe/set-env | ||||||||||||
|
||||||||||||
- name: Install and Start DDEV | ||||||||||||
uses: ./.github/actions/drainpipe/ddev | ||||||||||||
- name: Delete sticky pull request comment | ||||||||||||
uses: marocchino/sticky-pull-request-comment@v2 | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deviantintegral suggests that we pin to a commit hash so future releases don't unexpectedly break our builds. |
||||||||||||
with: | ||||||||||||
git-name: Drainpipe Bot | ||||||||||||
git-email: no-reply@example.com | ||||||||||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||||||||||||
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | ||||||||||||
|
||||||||||||
- name: Build Project | ||||||||||||
run: ddev composer install | ||||||||||||
|
||||||||||||
- name: Install composer lock diff | ||||||||||||
run: ddev composer global require davidrjonas/composer-lock-diff:^1.0 | ||||||||||||
header: composer-lock-diff | ||||||||||||
delete: true | ||||||||||||
|
||||||||||||
- name: Prepare repository | ||||||||||||
run: | | ||||||||||||
git reset --soft HEAD^1 | ||||||||||||
git reset . | ||||||||||||
- name: Generate composer diff | ||||||||||||
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }} | ||||||||||||
id: composer-diff | ||||||||||||
uses: IonBazan/composer-diff-action@v1 | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deviantintegral suggests that we pin to a commit hash so future releases don't unexpectedly break our builds. |
||||||||||||
with: | ||||||||||||
with-platform: true | ||||||||||||
with-links: true | ||||||||||||
Comment on lines
+34
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to also include the underlying CLI command in ddev via a Dockerfile? That way, developers are one step closer to debugging things when they go wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really think so, and I would actually advocate for removing composer-lock-diff as a task/command. I never found a need for it to run this locally in the same way that it does with the action. I could just always debug the action itself or report an issue upstream with the community action. It is worth noting this is a change from using https://github.com/davidrjonas/composer-lock-diff to https://github.com/IonBazan/composer-diff. There are more benefits to this change relating to maintained code and Github Actions support:
That said, having just the |
||||||||||||
|
||||||||||||
- name: Run composer lock diff | ||||||||||||
run: | | ||||||||||||
curl -f \ | ||||||||||||
-H "Accept: application/vnd.github+json" \ | ||||||||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||||||||||||
https://api.github.com/repos/${{ github.repository }}/pulls/$DRAINPIPE_PR_NUMBER | jq '. | {body}' > pull_request.json | ||||||||||||
ddev task "github:composer-lock-diff pull_request='pull_request.json' json_file='processed.json'" | ||||||||||||
curl -f \ | ||||||||||||
-X PATCH \ | ||||||||||||
-H "Accept: application/vnd.github+json" \ | ||||||||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||||||||||||
https://api.github.com/repos/${{ github.repository }}/pulls/$DRAINPIPE_PR_NUMBER \ | ||||||||||||
-d @processed.json | ||||||||||||
- name: Post sticky pull request comment | ||||||||||||
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }} | ||||||||||||
uses: marocchino/sticky-pull-request-comment@v2 | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deviantintegral suggests that we pin to a commit hash so future releases don't unexpectedly break our builds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we get notified of new releases to update the hash to? Monitor the log files for deprecation notices? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I agree that locking it down to commit hashes is better for security, the problem becomes when we need to update the workflows to all the consumers, or any repositories haven't been updated in a while, their actions could potentially break due to GitHub changes. It's a trade-off that we can balance with only doing it for very specific, trusted actions. |
||||||||||||
with: | ||||||||||||
header: composer-lock-diff | ||||||||||||
message: | | ||||||||||||
### Composer package changes | ||||||||||||
${{ (steps.composer-diff.outcome != 'success' && 'Review any changes to composer.lock manually.') || steps.composer-diff.outputs.composer_diff || 'No changes found' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deviantintegral suggests that we pin to a commit hash so future releases don't unexpectedly break our builds.