Add auto-update workflow
This commit is contained in:
83
.gitea/workflows/auto-update.yaml
Normal file
83
.gitea/workflows/auto-update.yaml
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Based on https://github.com/infinilabs/gitea-pr/blob/main/action.yml
|
||||||
|
|
||||||
|
name: Auto update flake.lock
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch: # allows manual triggering
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
auto-update:
|
||||||
|
runs-on: basic-nix
|
||||||
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set git bot info
|
||||||
|
run: >-
|
||||||
|
git config user.email "noreply@notadev.net" &&
|
||||||
|
git config user.name "Update bot"
|
||||||
|
|
||||||
|
- name: Login to Gitea
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SERVER_URL: tea.notadev.net
|
||||||
|
SERVER_TOKEN: ${{ secrets.token }}
|
||||||
|
SERVER_USER: ${{ secrets.user }}
|
||||||
|
SERVER_PASSWORD: ${{ secrets.password }}
|
||||||
|
run: >-
|
||||||
|
cd "${{ env.GITHUB_WORKSPACE }}" &&
|
||||||
|
echo "$PWD" &&
|
||||||
|
export GITEA_SERVER_URL="$SERVER_URL" &&
|
||||||
|
export GITEA_SERVER_TOKEN="$SERVER_TOKEN" &&
|
||||||
|
export GITEA_SERVER_USER="$SERVER_USER" &&
|
||||||
|
export GITEA_SERVER_PASSWORD="$SERVER_PASSWORD" &&
|
||||||
|
export XDG_CONFIG_HOME="$PWD" &&
|
||||||
|
tea login add --scopes "write:activitypub, write:notification, write:issue, write:misc, write:organization, write:package, write:repository, write:user"
|
||||||
|
|
||||||
|
- name: Update flake.lock
|
||||||
|
run: nix flake update
|
||||||
|
|
||||||
|
- name: Create new commit
|
||||||
|
run: >-
|
||||||
|
git checkout -b update-lockfile &&
|
||||||
|
git add flake.lock &&
|
||||||
|
git commit -m "Update flake.lock" &&
|
||||||
|
git push origin update-lockfile
|
||||||
|
|
||||||
|
- name: Create PR
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SERVER_URL: tea.notadev.net
|
||||||
|
SERVER_TOKEN: ${{ secrets.token }}
|
||||||
|
SERVER_USER: ${{ secrets.user }}
|
||||||
|
SERVER_PASSWORD: ${{ secrets.password }}
|
||||||
|
run: >-
|
||||||
|
cd "${{ env.GITHUB_WORKSPACE }}" &&
|
||||||
|
echo "$PWD" &&
|
||||||
|
export GITEA_SERVER_URL="$SERVER_URL" &&
|
||||||
|
export GITEA_SERVER_TOKEN="$SERVER_TOKEN" &&
|
||||||
|
export GITEA_SERVER_USER="$SERVER_USER" &&
|
||||||
|
export GITEA_SERVER_PASSWORD="$SERVER_PASSWORD" &&
|
||||||
|
export XDG_CONFIG_HOME="$PWD" &&
|
||||||
|
export XDG_CONFIG_HOME="$PWD" &&
|
||||||
|
tea pr create --title "Update flake.lock"
|
||||||
|
|
||||||
|
- name: Merge PR
|
||||||
|
shell: nu
|
||||||
|
run: |
|
||||||
|
cd "${{ env.GITHUB_WORKSPACE }}"
|
||||||
|
echo $env.PWD
|
||||||
|
let $index = tea pr list --fields "index,head" --output csv
|
||||||
|
| from csv
|
||||||
|
| where head =~ update-lockfile
|
||||||
|
| select index
|
||||||
|
| first 1
|
||||||
|
tea pr merge
|
||||||
|
|
||||||
|
- name: Delete branch
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
git branch -d update-lockfile
|
||||||
|
git push origin :update-lockfile
|
||||||
Reference in New Issue
Block a user