-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This workflow builds the action if it wasn't built already by the pre-commit hook | ||
# and push it in a new commit | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: ~ | ||
workflow_dispatch: ~ | ||
|
||
jobs: | ||
build: | ||
if: github.actor != 'dependabot[bot]' && github.actor != 'github-actions[bot]' && !github.event.pull_request.head.repo.fork | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref || github.ref }} | ||
token: ${{ secrets.REBUILD_PUSH_TOKEN }} | ||
|
||
- name: Git config | ||
run: | | ||
git config --global user.email "github-actions@example.com" | ||
git config --global user.name "github-actions[bot]" | ||
- uses: actions/setup-node@v4 | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build index.js | ||
run: npm run build | ||
|
||
- name: Check Git status | ||
id: git_status | ||
run: | | ||
GIT_STATUS_OUTPUT=$(git status --porcelain) | ||
if [[ -n "$GIT_STATUS_OUTPUT" ]]; then | ||
echo "GIT_STATUS_MODIFIED=true" >> $GITHUB_ENV | ||
else | ||
echo "GIT_STATUS_MODIFIED=false" >> $GITHUB_ENV | ||
fi | ||
- name: Commit & push index.js | ||
# Push only if the built index.js has changed. | ||
if: env.GIT_STATUS_MODIFIED == 'true' | ||
run: | | ||
git add dist/index.js | ||
git commit -m "Build index.js" | ||
git push origin ${{ github.head_ref || github.ref }} |