Last active
February 15, 2025 05:07
-
-
Save mattfsourcecode/1587fcce99c4cd6bccbaaebb5550771e to your computer and use it in GitHub Desktop.
Collection of GitHub Actions workflows for CI automation and package management.
This file contains hidden or 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: Dependabot Auto Merge and Resolve Lockfile Conflicts | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- opened | |
- synchronize | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
resolve-conflicts: | |
if: github.event.pull_request.user.login == 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: pnpm | |
- name: Install dependencies (skip prepare script) | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Check for lockfile conflicts | |
id: check-lockfile | |
run: | | |
if git diff --name-only | grep 'pnpm-lock.yaml'; then | |
echo "conflict=true" >> $GITHUB_OUTPUT | |
else | |
echo "conflict=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Resolve lockfile conflict | |
if: steps.check-lockfile.outputs.conflict == 'true' | |
run: | | |
echo "Deleting pnpm-lock.yaml..." | |
rm pnpm-lock.yaml | |
echo "Reinstalling dependencies..." | |
pnpm install | |
- name: Commit and push updated lockfile | |
if: steps.check-lockfile.outputs.conflict == 'true' | |
run: | | |
git config --global user.name "dependabot-bot" | |
git config --global user.email "[email protected]" | |
git add pnpm-lock.yaml | |
git commit -m "fix: Resolve pnpm-lock.yaml conflicts" | |
git push origin ${{ github.event.pull_request.head.ref }} | |
auto-merge: | |
needs: resolve-conflicts | |
if: github.event.pull_request.user.login == 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch Dependabot metadata | |
id: metadata | |
uses: dependabot/fetch-metadata@v1 | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Enable auto-merge for Dependabot PRs | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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
version: 2 | |
updates: | |
- package-ecosystem: "npm" | |
directory: "/" | |
schedule: | |
interval: "daily" | |
commit-message: | |
prefix: "deps" | |
open-pull-requests-limit: 5 | |
labels: | |
- "dependencies" | |
allow: | |
- dependency-type: "all" | |
groups: | |
all-dependencies: | |
patterns: | |
- "*" | |
update-types: ["minor", "patch", "major"] | |
applies-to: "version-updates" |
This file contains hidden or 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: General CI Workflow | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test-and-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
cache: "pnpm" | |
- name: Install dependencies (skip prepare script) | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Run tests | |
run: pnpm test | |
- name: Build the project | |
run: pnpm build |
This file contains hidden or 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: Update pnpm Version and Auto-Merge | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update-pnpm: | |
runs-on: ubuntu-latest | |
outputs: | |
pull_request_url: ${{ steps.create-pr.outputs.pull-request-url }} | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Install zsh | |
run: sudo apt-get update && sudo apt-get install -y zsh | |
- name: Install Corepack | |
run: npm install -g corepack | |
- name: Update pnpm Version | |
run: corepack up | |
- name: Create a pull request | |
id: create-pr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: update-pnpm-version | |
title: "chore: Update pnpm version via Corepack" | |
body: "This pull request updates the pnpm version in package.json using Corepack." | |
labels: update, dependencies | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
auto-merge: | |
needs: update-pnpm | |
runs-on: ubuntu-latest | |
if: needs.update-pnpm.outputs.pull_request_url != '' | |
steps: | |
- name: Enable auto-merge for the pull request | |
run: gh pr merge --auto --merge "${{ needs.update-pnpm.outputs.pull_request_url }}" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment