Skip to content

Commit

Permalink
Add untested automatic update script
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblock committed May 10, 2021
1 parent 006fcb8 commit f89e04c
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Main

on: [push, pull_request]
on:
push:
branches-ignore:
- 'npm-check-updates'
pull_request:

jobs:
test-install-and-run-from-git:
Expand Down
143 changes: 143 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Update Dependencies, Test, and Commit

# Continuously update dependencies of this package and test with all versions of node on various OSes

on:
schedule:
# Every Saturday at 5:00am
- cron: 0 5 * * 6

jobs:
update:
runs-on: ubuntu-latest
name: Update Dependencies
steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc

- name: Checkout latest code
uses: actions/checkout@v2
with:
ref: master
fetch-depth: 0

- name: Install Node
uses: actions/setup-node@v2

- name: 'Debug: Node version'
run: node --version

# Update all dependencies
- name: 'Update dependencies'
run: npx npm-check-updates -u --packageManager yarn
env:
FORCE_COLOR: 1

# Install dependencies and Build
- name: Install dependencies and Build (using `yarn install`)
run: yarn install

- name: 'Info: Show differences'
run: git diff --color=always

- name: Clean touched but identical files
run: 'git update-index --refresh || :'

- name: Test for changes (don't continue if there aren't any)
id: changes
run: '! git diff-index --quiet HEAD --'

# TODO: bail out "successfully" here instead of as "error"
- name: Switch to update branch
run: git checkout -b npm-check-updates

- name: Add expected file changes
run: git add package.json yarn.lock

- name: Set Author
run: |
git config user.email actions@github.com
git config user.name GitHub Actions
- name: 'Commit changes'
run: git commit -m 'Automatic dependency update'

- name: Test for dangling changes (error if any remain!)
run: git diff-index --quiet HEAD --

- name: Push to GitHub
run: git push origin npm-check-updates --force

test-matrix:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # There are problems on various architectures on lower versions that are more work to fix. Please open an issue if you need more version support

runs-on: ${{ matrix.os }}

needs: update

name: Test with Node ${{ matrix.node }} on ${{ matrix.os }}

steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc

- name: Checkout latest code
uses: actions/checkout@v2
with:
ref: npm-check-updates

- name: Install Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: 'Debug: Node version'
run: node --version

# Install dependencies and Build
- name: Install dependencies and Build (using `yarn install --frozen-lockfile`)
run: yarn install --frozen-lockfile

- name: 'Info: Show differences'
run: git diff --color=always

- name: Test Code
run: yarn test --ci

merge:
name: 'Merge updates into master'

needs: test-matrix

runs-on: ubuntu-latest

steps:
- name: Enable color for Npm output
run: echo color = always >> .npmrc

- name: Checkout latest code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: master

- name: Merge
run: git merge --ff-only origin/npm-check-updates

- name: Set Author
run: |
git config user.email actions@github.com
git config user.name GitHub Actions
- name: Bump Version
run: yarn version --patch

- name: Push
run: git push --tags --atomic origin master

- name: Cleanup
run: git branch -d origin/npm-check-updates
2 changes: 2 additions & 0 deletions .github/workflows/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Test All Versions

on:
push:
branches-ignore:
- 'npm-check-updates'
pull_request:
repository_dispatch:
schedule:
Expand Down

0 comments on commit f89e04c

Please sign in to comment.