Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/dependabot #7

Merged
merged 16 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
102 changes: 102 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Tests and Dependabot PR Handling

on:
pull_request:
branches:
- master
- main

jobs:
# Verifies the boilerplate can start and run in GitHub Actions environment
test-for-workflow:
name: Alva test workflow
uses: DevSkillsHQ/publish-test-results-workflow/.github/workflows/publish-test-results.yml@main

# Verifies the boilerplate can start and run in codespace environment
test-for-codespaces:
runs-on: ubuntu-20.04
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 jq
run: sudo apt-get install jq
- name: Fetch apiUrl
run: |
apiUrl=$(grep "apiUrl:" cypress.config.js | awk -F": " '{print $2}' | tr -d "'," || echo "")

if [[ ! -z "$apiUrl" ]]; then
apiUrl="$apiUrl/ping"
fi

echo "apiUrl=$apiUrl" >> $GITHUB_ENV

shell: bash
# Running tests for all challenges except Backend.
- name: Run tests without waiting on API
if: env.apiUrl == ''
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm run start
- name: Run tests with waiting on API
if: env.apiUrl != ''
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm run start
wait-on: ${{ env.apiUrl }}

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 }}
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

auto-merge:
needs: check-dependabot
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
});
40 changes: 0 additions & 40 deletions .github/workflows/tests.yml

This file was deleted.

Loading
Loading