Skip to content

ci: Refresh and commit manifest files for patch PRs #3

ci: Refresh and commit manifest files for patch PRs

ci: Refresh and commit manifest files for patch PRs #3

Workflow file for this run

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
- 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 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 "action@github.com"
git config --local user.name "GitHub Action"
git add manifests
# 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.ref_name }}