.github/workflows/dependency-update.yml
name: Dependency Update
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
jobs:
upgrade-dependencies:
runs-on: ubuntu-20.04
env:
deps_branch_name: dep-update
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
fetch-depth: 0
# We deliberately do not use the setup action, as we do not want node caching here.
- name: Configure direnv
uses: HatsuneMiku3939/direnv-action@v1
- name: Install Node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Upgrade all node dependencies
id: upgrade
run: |
lockfiles=(`find . -name "yarn.lock" ! -path '*/node_modules/*'`)
for i in "${lockfiles[@]}"
do
yarn --cwd "${i%/*}" upgrade
done
if [ "$(git status --porcelain)" ]; then
echo "::set-output name=changes::true"
fi
- name: Commit code to deps branch
if: ${{ steps.upgrade.outputs.changes }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git branch -D $deps_branch_name || true
git checkout -b $deps_branch_name
git commit -a -m "chore(deps): Upgrade all node dependencies"
git push --set-upstream origin $deps_branch_name --force
- name: Slack Notification - notify of failure
uses: rtCamp/action-slack-notify@v2
if: env.SLACK_WEBHOOK != '' && failure()
env:
SLACK_COLOR: ${{job.status}}
SLACK_ICON: https://github.com/${{ github.repository_owner }}.png?size=48
SLACK_TITLE: Failure
SLACK_USERNAME: ${{ github.repository }} ${{job.status}}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Slack Notification - notify of success
uses: rtCamp/action-slack-notify@v2
if: env.SLACK_WEBHOOK != ''
env:
SLACK_COLOR: ${{job.status}}
SLACK_ICON: https://github.com/${{ github.repository_owner }}.png?size=48
SLACK_TITLE: Update Dependencies Workflow - SUCCESS
SLACK_MESSAGE: Click https://github.com/${{ github.repository }}/compare/master...${{ env.deps_branch_name }}?quick_pull=1&labels=deps&title=chore(deps):+Update+Dependencies&body=Update+all+dependencies. to create a PR for the updates to go to master.
SLACK_USERNAME: ${{ github.repository }} ${{job.status}}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}