mirror of
https://github.com/danog/sass-site.git
synced 2024-11-27 12:35:03 +01:00
60 lines
2.0 KiB
YAML
60 lines
2.0 KiB
YAML
name: Upgrade dependencies
|
|
|
|
on:
|
|
workflow_dispatch: # Allow running on-demand
|
|
schedule:
|
|
# Every Monday at 8:00 UTC (4:00 Eastern)
|
|
- cron: '0 8 * * 1'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
upgrade:
|
|
name: Upgrade & Open Pull Request
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
BRANCH_NAME: auto-dependency-upgrades
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
# Use a separate key so the resulting PR also runs GH Actions
|
|
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
|
|
ssh-key: ${{ secrets.DEPLOY_KEY }}
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: yarn
|
|
- name: Upgrade dependencies
|
|
run: |
|
|
rm -f yarn.lock
|
|
npx --yes yarn-upgrade-all
|
|
- name: Build
|
|
run: yarn build
|
|
- name: Detect changes
|
|
id: changes
|
|
run: echo "count=$(git status --porcelain=v1 2>/dev/null | wc -l)" >> $GITHUB_OUTPUT
|
|
- name: Commit & push changes
|
|
if: steps.changes.outputs.count > 0
|
|
run: |
|
|
git config user.name github-actions
|
|
git config user.email github-actions@github.com
|
|
git add .
|
|
git commit -m "chore(deps): Automated dependency upgrades"
|
|
git push -f origin ${{ github.ref_name }}:$BRANCH_NAME
|
|
- name: Open pull request if needed
|
|
if: steps.changes.outputs.count > 0
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
PR=$(gh pr list --head $BRANCH_NAME --json number -q '.[0].number')
|
|
if [ -z $PR ]; then
|
|
gh pr create \
|
|
--head $BRANCH_NAME \
|
|
--title "Automated dependency upgrades" \
|
|
--body "Full log: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
else
|
|
echo "Pull request already exists, won't create a new one."
|
|
fi
|