chore: update pr-build.yaml #24
Workflow file for this run
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
name: Pull Request Build | |
on: | |
pull_request: | |
branches: | |
- develop | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Build Next.js | |
run: | | |
bun install --frozen-lockfile | |
bun lint | |
bun run build | |
- name: Check Build Status | |
run: | | |
if [ $? -eq 0 ]; then | |
echo "Build successful" | |
else | |
echo "Build failed. Exiting..." | |
exit 1 | |
fi | |
- name: Comment on Pull Request | |
env: | |
GH_TOKEN: ${{ secrets.WF_TOKEN }} | |
PR: ${{ github.event.pull_request.html_url }} | |
run: | | |
LAST_COMMIT_SHA="${{ github.event.pull_request.head.sha }}" | |
if [[ ${{ job.status }} == 'success' ]]; then | |
BUILD_STATUS="Berhasil🩵" | |
LABEL="ready to review" | |
SUCCESS_MESSAGE="Mohon untuk menunggu para Maintainer mereview kodemu🎉!" | |
REMOVAL_LABEL="invalid" | |
else | |
BUILD_STATUS="Gagal💔" | |
LABEL="invalid" | |
SUCCESS_MESSAGE="Sepertinya ada kesalahan dalam kode yang menyebabkan kegagalan build. Silahkan perbaiki terlebih dahulu😼!" | |
REMOVAL_LABEL="ready to review" | |
fi | |
COMMENT_BODY=$(cat <<EOF | |
# Building Next.js | |
Build untuk pull request ini $BUILD_STATUS. $SUCCESS_MESSAGE | |
| Commit | Status | | |
|-------------|-----------| | |
| $LAST_COMMIT_SHA | $BUILD_STATUS | | |
EOF | |
) | |
gh pr edit $PR --add-label "$LABEL" | |
gh pr edit $PR --remove-label "$REMOVAL_LABEL" | |
gh pr comment $PR --body "$COMMENT_BODY" |