Skip to content

Commit

Permalink
Add workflow to build action
Browse files Browse the repository at this point in the history
  • Loading branch information
figi44 committed Nov 15, 2023
1 parent 22e6624 commit 71c8a1d
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
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 }}

0 comments on commit 71c8a1d

Please sign in to comment.