Skip to content

Commit

Permalink
test: patch-hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
nilp0inter committed Jul 11, 2024
1 parent c81c4ae commit dbe55be
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/build-and-cache-chore-patch-hashes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Cache on Push

on:
push:
branches:
- chore/patch-hashes
pull_request:

permissions:
contents: read

jobs:
build-and-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: autofirma-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: build autofirma-nix
shell: /usr/bin/bash -o pipefail -e {0}
run: |
# nix flake metadata --update-input nixpkgs
nix build -L .#autofirma .#configuradorfnmt .#dnieremote 2>&1 | .github/workflows/replace_mismatching_hashes.pl
nix build --json .#autofirma .#configuradorfnmt .#dnieremote | jq -r '.[].outputs | to_entries[].value' | cachix push autofirma-nix
- name: Create Pull Request
if: failure()
uses: peter-evans/create-pull-request@v6
with:
commit-message: 'update: hashes'
add-paths: nix
branch: chore/patch-hashes/update
25 changes: 25 additions & 0 deletions .github/workflows/replace_mismatching_hashes.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env perl
use strict;
use warnings;

my $specified_hash = "";
my $got_hash = "";

while (my $line = <STDIN>) {
print $line;

if ($line =~ /specified:\s+(\S+)/) {
$specified_hash = $1;
} elsif ($line =~ /got:\s+(\S+)/) {
$got_hash = $1;
}

if ($specified_hash && $got_hash) {
my $command = "find . -type f -name '*.nix' -print0 | xargs -0 sed -i -e 's/$specified_hash/$got_hash/g'";
system($command);
print "Executed: $command\n";

$specified_hash = "";
$got_hash = "";
}
}
2 changes: 1 addition & 1 deletion nix/autofirma/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
owner = "ctt-gob-es";
repo = "jmulticard";
rev = "v1.8";
hash = "sha256-sCqMK4FvwRHsGIB6iQVyqrx0+EDiUfQSAsPqmDq2Giw=";
hash = "sha256-sCqMK3FvwRHsGIB6iQVyqrx0+EDiUfQSAsPqmDq2Giw=";
};
patches = [
./patches/jmulticard/javaversion.patch
Expand Down

0 comments on commit dbe55be

Please sign in to comment.