Package Updater #783
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package Updater | |
on: | |
schedule: | |
- cron: "5 1 * * *" | |
workflow_dispatch: {} | |
jobs: | |
generate_matrix: | |
runs-on: ubuntu-22.04 | |
outputs: | |
packages: ${{ steps.gen_packages.outputs.packages }} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
token: "${{ secrets.GH_TOKEN }}" | |
- name: Install nix | |
uses: ./.github/actions/setup-env | |
with: | |
github_token: "${{ secrets.GH_TOKEN }}" | |
netrc_content: "${{ secrets.NETRC_CONTENT }}" | |
- name: Generate packages.json | |
run: | | |
nix eval --json .#packages.x86_64-linux --apply 'builtins.mapAttrs(name: value: builtins.hasAttr "runUpdate" value && value.runUpdate)' > packages.json | |
- id: gen_packages | |
run: | | |
packages=$(jq -c 'map_values(select (.)) | keys' < packages.json) | |
echo packages=$packages >> $GITHUB_OUTPUT | |
update_packages: | |
runs-on: ubuntu-22.04 | |
needs: [generate_matrix] | |
strategy: | |
fail-fast: false | |
max-parallel: 10 | |
matrix: | |
package: ${{fromJson(needs.generate_matrix.outputs.packages)}} | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
token: "${{ secrets.GH_TOKEN }}" | |
- name: Install nix | |
uses: ./.github/actions/setup-env | |
with: | |
github_token: "${{ secrets.GH_TOKEN }}" | |
netrc_content: "${{ secrets.NETRC_CONTENT }}" | |
- name: Set up git | |
run: | | |
git config user.email git@pointjig.de | |
git config user.name "Git Bot" | |
- name: Update package | |
run: nix run nixpkgs\#nix-update -- --build --commit --flake ${{ matrix.package }} | |
- name: Push branch and create PR | |
run: | | |
UPSTREAM=${1:-'@{u}'} | |
LOCAL=$(git rev-parse @) | |
REMOTE=$(git rev-parse "$UPSTREAM") | |
BASE=$(git merge-base @ "$UPSTREAM") | |
if [ $LOCAL = $REMOTE ]; then | |
exit 0 | |
fi | |
git switch -c updates-${{ matrix.package }}_$(date -I) | |
git push -u origin updates-${{ matrix.package }}_$(date -I) | |
PR=$(gh pr create \ | |
--base main \ | |
--body "Automatic package update for ${{ matrix.package }} on $(date -I)" \ | |
--fill \ | |
--label bot --label ${{ matrix.package }} \ | |
--title "Package update for ${{ matrix.package }} $(date -I)") | |
env: | |
GH_TOKEN: ${{ github.token }} |