-
Notifications
You must be signed in to change notification settings - Fork 56
58 lines (55 loc) · 1.81 KB
/
patch-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Patch PR
on:
pull_request:
paths:
- 'patches.nix'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
refresh-and-commit:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v12
with:
name: fuellabs
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix flake update
- run: nix run .#refresh-manifests
timeout-minutes: 120
- name: validate changed nix files
run: |
files=( $(git diff --name-only '*.nix') )
echo "${#files[*]} nix files changed: ${files[*]}"
if [[ "${#files[*]}" -ne 0 ]]; then
nix-instantiate --parse "${files[@]}" >/dev/null
fi
- name: Check and commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add manifests flake.lock
# Check if there are any changes to commit
if git diff --staged --quiet; then
echo "No changes to commit."
exit 0
else
git commit -m "ci: refresh manifests for patch PR"
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.REPO_TOKEN }}
branch: ${{ github.head_ref }}