Skip to content

Commit

Permalink
chore: add update dep workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Feb 19, 2024
1 parent 0f3d11d commit 12d1872
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/update-dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Update a dependency On-Demand

name: Update dependency On-Demand

on:
workflow_dispatch:
inputs:
dep:
description: 'Dependency'
required: true
default: '@yao-pkg/pkg-fetch'
version:
description: 'Version'
required: false
default: ''

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write

steps:
- uses: actions/checkout@v3

- name: Use Node.js 20
uses: actions/setup-node@v3.6.0
with:
node-version: 20.x
cache: 'yarn'

- name: Update dependency
run: |
yarn add ${{github.event.inputs.dep}}@${{github.event.inputs.version || 'latest'}}
- name: Check for changes
id: check
run: |
git diff --name-only || true
if ! git diff --quiet ; then
echo "Has changes"
echo "changed=true" >> $GITHUB_OUTPUT
VERSION=$(npm info ${{github.event.inputs.dep}} version)
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "No changes detected. Dependency already up to date"
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: ${{ steps.check.outputs.changed == 'true' }}
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "feat: bump ${{github.event.inputs.dep}}@${{ steps.check.outputs.version }}"
branch: "${{github.event.inputs.dep}}@${{ steps.check.outputs.version }}"
delete-branch: true
title: "feat: bump ${{github.event.inputs.dep}}@${{ steps.check.outputs.version }}"
body: |
Update ${{github.event.inputs.dep}} to version ${{ steps.check.outputs.version }}
labels: |
dependencies
workflow-bump
base: main
draft: false

- name: Check outputs
if: ${{ steps.check.outputs.changed == 'true' }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 comments on commit 12d1872

Please sign in to comment.