Update Hash #1516
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: Update Hash | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */4 * * *" | |
env: | |
BRANCH: update-${{ github.run_number }} | |
jobs: | |
get-update-scripts: | |
runs-on: ubuntu-latest | |
outputs: | |
update-scripts: ${{ steps.get-update-scripts.outputs.update-scripts }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get update scripts | |
id: get-update-scripts | |
shell: bash # Set pipefail | |
run: echo "update-scripts=$(find . -name "update.sh" | jq -cnR '[inputs]')" >> "$GITHUB_OUTPUT" | |
update: | |
runs-on: ubuntu-latest | |
needs: get-update-scripts | |
strategy: | |
fail-fast: false | |
matrix: | |
update-script: ${{ fromJson(needs.get-update-scripts.outputs.update-scripts) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
extra_nix_config: experimental-features = nix-command flakes | |
- name: Run update script | |
continue-on-error: true | |
run: |- | |
${{ matrix.update-script }} | |
git stash | |
git pull | |
git stash pop | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
continue-on-error: true | |
with: | |
commit_message: | | |
pkgs: autoupdate | |
uwu | |
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
branch: ${{ env.BRANCH }} | |
push_options: --atomic | |
create_branch: true | |
squash-to-master: | |
if: always() | |
runs-on: ubuntu-latest | |
needs: update | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.UPDATE_HASH_TOKEN }} | |
- name: Check if branch exists | |
id: check-branch | |
run: '! git branch -r | grep $BRANCH; echo exists=$? >> "$GITHUB_OUTPUT"' | |
- name: Squash commits to master | |
if: steps.check-branch.outputs.exists == '1' | |
run: git merge --squash origin/$BRANCH | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
if: steps.check-branch.outputs.exists == '1' | |
with: | |
commit_message: | | |
pkgs: autoupdate | |
uwu | |
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
- name: Delete temporary branch | |
if: always() && steps.check-branch.outputs.exists == '1' | |
run: git push origin -d $BRANCH |