diff --git a/.github/npm-update.yml b/.github/npm-update.yml new file mode 100644 index 00000000..fdf2b337 --- /dev/null +++ b/.github/npm-update.yml @@ -0,0 +1,24 @@ +name: npm-update +on: + schedule: + - cron: '0 3 * * *' + workflow_dispatch: +jobs: + npm-update: + runs-on: ubuntu-latest + steps: + - name: Set up dependencies + run: sudo apt-get install -y npm make + + - name: Set up configuration and secrets + run: | + printf '[user]\n\tname = Cockpit Project\n\temail=cockpituous@gmail.com\n' > ~/.gitconfig + echo '${{ secrets.GITHUB_TOKEN }}' > ~/.config/github-token + + - name: Clone repository + uses: actions/checkout@v2 + + - name: Run npm-update bot + run: | + tools/make-bots + bots/npm-update diff --git a/.gitignore b/.gitignore index 97aa0974..387c74d6 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ yarn-error.log* coverage *~ +bots diff --git a/tools/make-bots b/tools/make-bots new file mode 100644 index 00000000..99d39c9d --- /dev/null +++ b/tools/make-bots @@ -0,0 +1,17 @@ +#!/bin/sh + +# Prepare bots by creating ./bots directory +# Specify $COCKPIT_BOTS_REF to checkout non-master branch + +set -e + +if [ ! -d bots ]; then + git clone --quiet --reference-if-able ${XDG_CACHE_HOME:-$HOME/.cache}/cockpit-project/bots https://github.com/cockpit-project/bots.git + if [ -n "$COCKPIT_BOTS_REF" ]; then + git -C bots fetch --quiet --depth=1 origin $COCKPIT_BOTS_REF + git -C bots checkout --quiet FETCH_HEAD + fi + echo "checked out bots/ ref $(git -C bots rev-parse HEAD)" +else + echo "bots/ already exists, skipping" +fi