Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/apply-reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ on:
outputs:
check-failed:
description: "Whether the check applied by this workflow 'failed'."
value: ${{ jobs.add-headers.outputs.made-change == 1 }}
value: ${{ jobs.add-headers.outputs.made-change }}
branch-created:
description: "If a branch was created, the name of that branch."
value: ${{ jobs.add-headers.outputs.made-change == 1 && jobs.add-headers.outputs.branch || '' }}
value: ${{ jobs.add-headers.outputs.made-change && jobs.add-headers.outputs.branch || '' }}
branches-deleted:
description: "If some branches were delete, what branches were they."
value: ${{ jobs.add-headers.outputs.deleted }}
Expand Down Expand Up @@ -86,27 +86,28 @@ jobs:
working-directory: ${{ inputs.work-dir }}
branch-prefix: add-license-headers-to
commit-message: Add License and Copyright Headers
exclude: .github/workflows/*

annotate:
runs-on: ubuntu-latest
concurrency: prune:bot-comments
needs: add-headers
steps:
- name: Commit comment
if: needs.add-headers.outputs.made-change == 1
if: needs.add-headers.outputs.made-change
uses: peter-evans/commit-comment@v4
with:
body: >
Copyright updates at [.../compare/${{ inputs.branch }}...${{ needs.add-headers.outputs.branch }}](${{ github.server_url }}/${{ github.repository }}/compare/${{ inputs.branch }}...${{ needs.add-headers.outputs.branch }}?expand=1), please review and merge.

- name: Hide old PR comments
if: needs.add-headers.outputs.made-change == 0
if: ${{ !needs.add-headers.outputs.made-change }}
uses: kanga333/comment-hider@v0.4.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: PR comment
if: needs.add-headers.outputs.made-change == 1
if: needs.add-headers.outputs.made-change
uses: mshick/add-pr-comment@v2
with:
refresh-message-position: true
Expand All @@ -115,7 +116,7 @@ jobs:
There are copyright updates on the (temporary) [${{ needs.add-headers.outputs.branch }} branch](${{ github.server_url }}/${{ github.repository }}/compare/${{ inputs.branch }}...${{ needs.add-headers.outputs.branch }}?expand=1). Please review and merge, or add further commits (this branch will be deleted).

- name: Fail marker
if: needs.add-headers.outputs.made-change == 1
if: needs.add-headers.outputs.made-change
uses: actions/github-script@v8
with:
script: |
Expand Down
4 changes: 2 additions & 2 deletions git-push-changes-to-branch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Example:
* `branch`

The name of the branch that may have been created.
NB: The branch is only created if the `changed` output is `1`.
NB: The branch is only created if the `changed` output is `true`.

* `changed`

Whether there were any changes committed. (`1` if yes, `0` if no.)
Whether there were any changes committed. (`true` if yes, `false` if no.)

## Permissions
Required permission:
Expand Down
23 changes: 19 additions & 4 deletions git-push-changes-to-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ inputs:
description: >
The email address of the user to ascribe the commit to.
default: no-reply@github.com
exclude:
description: >
A pattern to describe what files to omit from the committed.
default: ""
outputs:
branch:
description: >
Expand All @@ -55,7 +59,7 @@ outputs:
changed:
description: >
Whether there were any changes committed.
value: ${{ steps.detect.outputs.changed }}
value: ${{ steps.detect.outputs.changed == 1 && steps.push.outputs.pushed == 1 }}
runs:
using: composite
steps:
Expand Down Expand Up @@ -92,14 +96,25 @@ runs:
USER_EMAIL: ${{ inputs.commit-user-email }}
- name: push changes
if: steps.detect.outputs.changed == 1
id: push
working-directory: ${{ inputs.working-directory }}
run: |
git checkout -b "$NEW_BRANCH"
git add -A
git commit -a -m "$MESSAGE"
git push origin "$NEW_BRANCH"
if [ -z "$EXCLUDE" ]; then
git add -A
else
git add --all -- "${EXCLUDE/#/:!}"
fi
if git diff --cached --exit-code >/dev/null; then
echo "pushed=0" >> $GITHUB_OUTPUT
else
git commit -a -m "$MESSAGE"
git push origin "$NEW_BRANCH"
echo "pushed=1" >> $GITHUB_OUTPUT
fi
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
NEW_BRANCH: ${{ steps.name.outputs.branch }}
MESSAGE: ${{ inputs.commit-message }}
EXCLUDE: ${{ inputs.exclude }}