make project open to contributions #43
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: Build 👷🏻♂️ | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm install | |
- name: Lint code | |
run: npm run lint | |
- name: Build app | |
run: npm run build | |
- name: Check for Lint/Build Errors | |
if: failure() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
core.setFailed("Linting or build errors detected. Please fix them and push again.") | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "Looks like you missed something Linting or build errors detected. Please fix them and push again." | |
}) | |
github.rest.checks.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: "Linting and Build Errors", | |
head_sha: context.sha, | |
status: "completed", | |
conclusion: "failure", | |
output: { | |
title: "Linting or Build Errors", | |
summary: "Linting/Build errors detected. Please fix them and push again." | |
} | |
}) | |
- name: If No Errors, Merge | |
if: success() | |
run: | | |
if [ -z "$(git diff --name-only ${{ github.sha }} ${{ github.event.before }})" ]; then | |
echo "No linting or build errors detected. Merging." | |
curl -X PUT \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/merge \ | |
-d '{"commit_title": "You Rock Thank you for your contribution! One core maintainer will review your changes and merge them if they are approved."}' | |
fi |