From c6b0622dbfce309e69d6d041ae2638f0966d31d2 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Wed, 14 Aug 2024 17:16:34 +0300 Subject: [PATCH] Github Workflows --- .github/workflows/format.yml | 26 ++++++++++++++++++++++++ .github/workflows/greet.yml | 39 ++++++++++++++++++++++++++++++++++++ prettier.config.js | 4 ++++ 3 files changed, 69 insertions(+) create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/greet.yml create mode 100644 prettier.config.js diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..6391b84 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,26 @@ +name: Run Format + +on: + push: + pull_request: + +jobs: + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "18" # Updated Node.js version + + - name: Install dependencies + run: npm install + + - name: Run script + run: npm run format:check # Replace with the path to your script diff --git a/.github/workflows/greet.yml b/.github/workflows/greet.yml new file mode 100644 index 0000000..111613d --- /dev/null +++ b/.github/workflows/greet.yml @@ -0,0 +1,39 @@ +name: Greet New PRs and Issues + +on: + pull_request: + types: [opened] + issues: + types: [opened] + +permissions: + issues: write + pull-requests: write + +jobs: + greet: + runs-on: ubuntu-latest + steps: + - name: Greet on PRs and Issues + uses: actions/github-script@v7 + with: + script: | + try { + const isPR = context.payload.pull_request !== undefined; + const number = isPR ? context.payload.pull_request.number : context.payload.issue.number; + const commentBody = isPR + ? `Hey there! 👋 Thanks for taking the time to send in this pull request. We are happy to have your contribution! If you have any questions or need any help, feel free to ask.` + : `Hello! 👋 Thanks for opening this issue. We appreciate your feedback and will look into it as soon as possible. Feel free to add more details if necessary.`; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: number, + body: commentBody + }); + + console.log('Comment successfully created.'); + } catch (error) { + console.error('Error creating comment:', error); + // Do not mark the step as failed; continue with the workflow. + } \ No newline at end of file diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..0dcd001 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,4 @@ +module.exports = { + tabWidth: 2, + useTabs: false, +};