Skip to content

Commit

Permalink
chore(ci): automatically handle dist folder in PRs and releases (#285)
Browse files Browse the repository at this point in the history
Co-authored-by: DerekRoberts <[email protected]>
  • Loading branch information
DerekRoberts and DerekRoberts authored Sep 12, 2024
1 parent 15681ec commit 7369e5b
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 31,766 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Merge

on:
push:
branches: [main]
paths:
- 'src/**'
- 'package-lock.json'
- 'package.json'
- 'tsconfig.json'
- 'action.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
semantic-release:
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.changelog.outputs.tag }}
version: ${{ steps.changelog.outputs.version }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Conventional Changelog Update
uses: TriPSs/conventional-changelog-action@v5
id: changelog
continue-on-error: true
with:
github-token: ${{ github.token }}
output-file: 'CHANGELOG.md'
skip-version-file: 'true'
skip-commit: 'true'
skip-on-empty: 'false'
git-push: 'true'

- uses: actions/[email protected]
with:
node-version: 20.x

- name: Rebuild the dist/ directory
run: npm run dist

- name: Git add dist/
run: git add dist/ lib/ -f

- name: Create Release
uses: softprops/action-gh-release@v2
if: ${{ steps.changelog.outputs.version != '' }}
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
with:
token: ${{ github.token }}
tag_name: ${{ steps.changelog.outputs.tag }}
name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}


- name: Create Release
uses: softprops/action-gh-release@v2
if: ${{ steps.changelog.outputs.version != '' }}
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
with:
token: ${{ github.token }}
tag_name: ${{ steps.changelog.outputs.tag.split('.')[0] }}
name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
38 changes: 9 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
name: PR
on:
pull_request:
push:
branches: [main]
workflow_dispatch:

jobs:
check-dist:
name: Check dist/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: 20.x

- name: Rebuild the dist/ directory
run: |
npm ci
npm run build
npm run package
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
test:
name: Test Action
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
# Rebuild ./dist
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
node-version: 20.x
- name: Rebuild the dist/ directory
run: npm run dist

# Test action
- uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,10 +29,9 @@ jobs:
[Links!](https://google.ca)
`Code!`
# Test with different inputs
- uses: ./
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
limit_to_pr_opened: true
add_markdown: |
---
Expand Down
Loading

0 comments on commit 7369e5b

Please sign in to comment.