refactor(fabric-items): use generic impl #581
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
--- | |
name: π Changelog | |
on: | |
pull_request: | |
types: [opened, reopened, labeled, unlabeled, synchronize] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref || null, github.head_ref || null) }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
jobs: | |
changelog-existence: | |
name: π Check Changelog | |
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') && github.actor != 'dependabot[bot]' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: βοΈ Check if changelog file was added | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: changelog_check | |
with: | |
filters: | | |
exists: | |
- added|modified: '.changes/unreleased/**.yaml' | |
- name: π§ Setup Go | |
if: steps.changelog_check.outputs.exists == 'true' | |
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: π§ Setup Task | |
if: steps.changelog_check.outputs.exists == 'true' | |
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
with: | |
repo-token: ${{ github.token }} | |
- name: π§ Setup Changie | |
if: steps.changelog_check.outputs.exists == 'true' | |
run: task install:changie | |
- name: π Find comment | |
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: github-actions[bot] | |
body-includes: "<!-- changelog -->" | |
- name: π Prepare comment (changelog) | |
if: steps.changelog_check.outputs.exists == 'true' | |
run: | | |
echo -e "# Changelog Preview\n" > changie.md | |
changie batch patch --dry-run --prerelease 'dev' >> changie.md | |
cat changie.md >> $GITHUB_STEP_SUMMARY | |
echo -e "\n<!-- changelog -->" >> changie.md | |
env: | |
CHANGIE_GITHUB_REPOSITORY: ${{ github.repository }} | |
- name: π Create comment (changelog) | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
if: steps.changelog_check.outputs.exists == 'true' && steps.fc.outputs.comment-id == '' | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: changie.md | |
- name: π Update comment (changelog) | |
if: steps.changelog_check.outputs.exists == 'true' && steps.fc.outputs.comment-id != '' | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
body-path: changie.md | |
edit-mode: replace | |
- name: π Prepare comment (missing) | |
if: steps.changelog_check.outputs.exists == 'false' | |
run: | | |
echo -e "# π Changelog entry required to merge\n" > changie.md | |
echo "Run \`changie new\` to add a new changelog entry" >> changie.md | |
cat changie.md >> $GITHUB_STEP_SUMMARY | |
echo -e "\n<!-- changelog -->" >> changie.md | |
- name: π Create comment (missing) | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
if: steps.changelog_check.outputs.exists == 'false' && steps.fc.outputs.comment-id == '' | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: changie.md | |
- name: π Update comment (missing) | |
if: steps.changelog_check.outputs.exists == 'false' && steps.fc.outputs.comment-id != '' | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
body-path: changie.md | |
edit-mode: replace | |
- name: β Pass if changelog entry exists | |
if: steps.changelog_check.outputs.exists == 'true' | |
run: | | |
echo "β Changelog entry exists." | |
exit 0 | |
- name: π Fail if changelog entry is missing and required | |
if: steps.changelog_check.outputs.exists == 'false' | |
run: | | |
echo "π Changelog entry required to merge." | |
exit 1 | |
changelog-skip: | |
name: π Check Changelog | |
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip-changelog') || github.actor == 'dependabot[bot]' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Find comment | |
if: github.actor != 'dependabot[bot]' | |
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: github-actions[bot] | |
body-includes: "<!-- changelog -->" | |
- name: ποΈ Delete comment | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: github.actor != 'dependabot[bot]' && steps.fc.outputs.comment-id != '' | |
with: | |
script: | | |
github.rest.issues.deleteComment({ | |
...context.repo, | |
comment_id: ${{ steps.fc.outputs.comment-id }}, | |
}); | |
- name: β Pass (skip) | |
run: exit 0 |