From 522ae1f857e0f26bb56da1cf202cfa82c882a1cc Mon Sep 17 00:00:00 2001 From: Ehsan Mirzarazi Date: Wed, 14 Feb 2024 11:48:48 +0100 Subject: [PATCH 1/5] feat: depandabot and auto merge pr github action added --- .github/workflows/tests.yml | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index fa35621..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Tests -on: - pull_request: - types: [opened, reopened] - push: - branches: - - '*' - - '!master' - - '!main' -jobs: - tests: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Fetch apiUrl - run: echo ::set-output name=apiUrl::$(jq -r .env.apiUrl cypress.json)/ping - id: fetchApiUrl - - name: Run tests - uses: cypress-io/github-action@v2 - with: - build: npm run build - start: npm run start - wait-on: ${{ steps.fetchApiUrl.outputs.apiUrl }} - - name: Set result_url env var - if: always() - run: echo "result_url=http://mockbin.com/request" >> $GITHUB_ENV - - name: Set github_repo env var - if: always() - run: echo "github_repo=$GITHUB_REPOSITORY" >> $GITHUB_ENV - - uses: joelwmale/webhook-action@master - if: failure() - with: - url: ${{ env.result_url }} - body: '{"assignmentRepository": "${{ env.github_repo }}","status": "failed"}' - - uses: joelwmale/webhook-action@master - if: success() - with: - url: ${{ env.result_url }} - body: '{"assignmentRepository": "${{ env.github_repo }}","status": "passed"}' From d437b3ed359254d706617d8452243c58a2705ad0 Mon Sep 17 00:00:00 2001 From: Ehsan Mirzarazi Date: Wed, 14 Feb 2024 12:00:36 +0100 Subject: [PATCH 2/5] feat: dependabot and auto merge action added --- .github/dependabot.yml | 19 +++++++++ .github/workflows/auto-merge.yml | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/auto-merge.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1e9c1be --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/app" + schedule: + interval: "daily" + labels: + - "npm" + - "dependencies" + + - package-ecosystem: "composer" + directory: "/app" + schedule: + interval: "daily" + labels: + - "dependencies" + - "php" + allow: + - dependency-type: "all" \ No newline at end of file diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 0000000..1ca464e --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,66 @@ +name: Dependabot PR Handling + +on: + pull_request: + types: [opened, reopened] + branches: + - master + - main + +jobs: + check-dependabot: + runs-on: ubuntu-20.04 + outputs: + is_dependabot_pr: ${{ steps.dependabot-check.outputs.is_dependabot_pr }} + steps: + - id: dependabot-check + name: Check if PR is from Dependabot + run: | + echo "PR author: ${{ github.event.pull_request.user.login }}" + if [[ "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" || "${{ github.event.pull_request.user.login }}" == "dependabot-preview[bot]" ]]; then + echo "::set-output name=is_dependabot_pr::true" + else + echo "::set-output name=is_dependabot_pr::false" + fi + + tests: + needs: check-dependabot + runs-on: ubuntu-20.04 + if: ${{ needs.check-dependabot.outputs.is_dependabot_pr == 'true' }} + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Run tests + uses: cypress-io/github-action@v2 + with: + build: npm run build + start: npm run start + + auto-merge: + needs: tests + runs-on: ubuntu-20.04 + if: ${{ needs.check-dependabot.outputs.is_dependabot_pr == 'true' }} + steps: + - name: Merge pull request + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pull_number = context.payload.pull_request.number; + await github.rest.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull_number + }); + + - name: Delete branch + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const branch_name = context.payload.pull_request.head.ref; + await github.rest.git.deleteRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'heads/' + branch_name + }); From a9bc38006a19602373ef16fa88d1c6be1bdf6d0c Mon Sep 17 00:00:00 2001 From: Ludvig Persson Date: Wed, 14 Feb 2024 13:49:14 +0100 Subject: [PATCH 3/5] feat: integrate tests for codespace environment --- .github/workflows/auto-merge.yml | 54 +++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 1ca464e..ff525fc 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,4 +1,4 @@ -name: Dependabot PR Handling +name: Tests and Dependabot PR Handling on: pull_request: @@ -8,7 +8,44 @@ on: - main jobs: + # Verifies the boilerplate can start and run in GitHub Actions environment + test-for-workflow: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run tests + uses: cypress-io/github-action@v5 + with: + build: npm run build + start: npm run start + + # Verifies the boilerplate can start and run in codespace environment + test-for-codespaces: + permissions: + contents: read + packages: read + container: + image: ghcr.io/devskillshq/boilerplate-base-image:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.github_token }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install + run: npm install + - name: Build + run: npm run build + - name: Start daemon + run: npm run start & + - name: Run tests + run: npm run test + check-dependabot: + needs: + - test-for-workflow + - test-for-codespaces runs-on: ubuntu-20.04 outputs: is_dependabot_pr: ${{ steps.dependabot-check.outputs.is_dependabot_pr }} @@ -23,21 +60,8 @@ jobs: echo "::set-output name=is_dependabot_pr::false" fi - tests: - needs: check-dependabot - runs-on: ubuntu-20.04 - if: ${{ needs.check-dependabot.outputs.is_dependabot_pr == 'true' }} - steps: - - name: Checkout - uses: actions/checkout@v1 - - name: Run tests - uses: cypress-io/github-action@v2 - with: - build: npm run build - start: npm run start - auto-merge: - needs: tests + needs: check-dependabot runs-on: ubuntu-20.04 if: ${{ needs.check-dependabot.outputs.is_dependabot_pr == 'true' }} steps: From bd28bb8f32a439bcfa2a3d9394eecc79536a033d Mon Sep 17 00:00:00 2001 From: Ludvig Persson Date: Wed, 14 Feb 2024 13:55:24 +0100 Subject: [PATCH 4/5] fix: run on all PR events --- .github/workflows/auto-merge.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index ff525fc..d96094e 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,11 +1,10 @@ name: Tests and Dependabot PR Handling on: - pull_request: - types: [opened, reopened] - branches: - - master - - main + pull_request: + branches: + - master + - main jobs: # Verifies the boilerplate can start and run in GitHub Actions environment From 3493d39d0b4ef571febc2eb3eb329a9226346203 Mon Sep 17 00:00:00 2001 From: Ludvig Persson Date: Wed, 14 Feb 2024 13:56:48 +0100 Subject: [PATCH 5/5] fix: add missing runs-on --- .github/workflows/auto-merge.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index d96094e..5b9341d 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -21,6 +21,7 @@ jobs: # Verifies the boilerplate can start and run in codespace environment test-for-codespaces: + runs-on: ubuntu-20.04 permissions: contents: read packages: read