15 Commits
v7 ... v10

Author SHA1 Message Date
2026a4bf1a Expose option to configure branch for PR (#36) 2022-06-22 15:44:48 -04:00
80619aa2cd flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/83658b28fe638a170a19b8933aa008b30640fbd1' (2022-05-26)
  → 'github:nixos/nixpkgs/e0169d7a9d324afebf5679551407756c77af8930' (2022-06-08)
2022-06-14 07:48:10 -07:00
357625ea1a flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/c777cdf5c564015d5f63b09cc93bef4178b19b01' (2022-05-05)
  → 'github:nixos/nixpkgs/83658b28fe638a170a19b8933aa008b30640fbd1' (2022-05-26)
2022-05-31 09:14:57 -07:00
86dd511c79 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/bc41b01dd7a9fdffd32d9b03806798797532a5fe' (2022-04-23)
  → 'github:nixos/nixpkgs/c777cdf5c564015d5f63b09cc93bef4178b19b01' (2022-05-05)
2022-05-10 07:49:17 -07:00
259c65e7d4 README: document an example that explicitly skips PRs 2022-05-03 12:25:41 -07:00
03e1d864c6 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/7b031d0d99e8cdaf0b70457c0cb33f16c0c958bb' (2021-11-30)
  → 'github:nixos/nixpkgs/bc41b01dd7a9fdffd32d9b03806798797532a5fe' (2022-04-23)
2022-04-29 09:32:51 -07:00
b044cabb79 README: example that prints the number of the opened PR 2022-04-22 11:46:11 -07:00
c58b7816fa Expose the number of the opened PR 2022-04-22 11:46:11 -07:00
614f33eec2 Resurrect CI and update actions 2022-04-05 08:50:00 -07:00
a10510d383 Add: script for update flake lock
Take commands out of the `action.yml` file, and put it in a dedicated
shell script.
2022-04-05 08:50:00 -07:00
e00d99112b fix: Re-introduce inputs.pr-title
This is to allow users to override the PR title since the commit message as well as title are processed differently which may lead to errors in how they are displayed. For example, the commit message needs quotations to be escaped
2022-02-01 10:43:22 -08:00
aa902c3538 fix: Support Custom Commit Message 2022-02-01 10:43:22 -08:00
V7
8c2dfef874 docs: Add information about Cosmetic Changes 2022-02-01 10:43:22 -08:00
V7
e8bb9f761a feat(cosmetic): Add Support for setting PR Labels 2022-02-01 10:43:22 -08:00
V7
073d38a53e feat(cosmetic): Add Support for Custom PR Title 2022-02-01 10:43:22 -08:00
6 changed files with 143 additions and 16 deletions

17
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v16
- name: Shellcheck
run: nix-shell --run 'shellcheck $(find . -type f -name "*.sh" -executable)'

19
.github/workflows/update.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: update-flake-lock
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v16
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: ./.

View File

@ -28,6 +28,11 @@ jobs:
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@vX
with:
pr-title: "Update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
```
## Example updating specific input(s)
@ -60,6 +65,65 @@ jobs:
inputs: input1 input2 input3
```
## Example that prints the number of the created PR
```yaml
name: update-flake-lock
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v16
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
id: update
uses: DeterminateSystems/update-flake-lock@vX
with:
inputs: input1 input2 input3
- name: Print PR number
run: echo Pull request number is ${{ steps.update.outputs.pull-request-number }}.
```
## Example that doesn't run on PRs
If you were to run this action as a part of your CI workflow, you may want to prevent it from running against Pull Requests.
```yaml
name: update-flake-lock
on:
workflow_dispatch: # allows manual triggering
pull_request: # triggers on every Pull Request
schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v16
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
if: ${{ github.event_name != 'pull_request' }}
uses: DeterminateSystems/update-flake-lock@vX
with:
inputs: input1 input2 input3
```
## Running GitHub Actions CI
GitHub Actions will not run workflows when a branch is pushed by or a PR is opened by a GitHub Action. There are two ways to have GitHub Actions CI run on a PR submitted by this action.

View File

@ -9,25 +9,38 @@ inputs:
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
required: false
default: ${{ github.token }}
commit-msg:
description: 'The message provided with the commit'
required: false
default: "flake.lock: Update"
branch:
description: 'The branch of the PR to be created'
required: false
default: "update_flake_lock_action"
pr-title:
description: 'The title of the PR to be created'
required: false
default: "flake.lock: Update"
pr-labels:
description: 'A comma or newline separated list of labels to set on the Pull Request to be created'
required: false
default: ''
outputs:
pull-request-number:
description: 'The number of the opened pull request'
value: ${{ steps.create-pr.outputs.pull-request-number }}
runs:
using: "composite"
steps:
- run: |
if [[ -n '${{ inputs.inputs }}' ]]; then
inputs=()
for input in ${{ inputs.inputs }}; do
inputs+=("--update-input" "$input")
done
nix flake lock "${inputs[@]}" --commit-lock-file
else
nix flake update --commit-lock-file
fi
- run: $GITHUB_ACTION_PATH/update-flake-lock.sh
shell: bash
env:
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: <github-actions[bot]@users.noreply.github.com>
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: <github-actions[bot]@users.noreply.github.com>
TARGETS: ${{ inputs.inputs }}
COMMIT_MSG: ${{ inputs.commit-msg }}
- run: |
content="$(git log --format=%b -n 1)"
content="${content//'%'/'%25'}"
@ -37,12 +50,14 @@ runs:
shell: bash
id: commit_message
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v3
with:
branch: update_flake_lock_action
branch: ${{ inputs.branch }}
delete-branch: true
title: "flake.lock: Update"
title: ${{ inputs.pr-title }}
token: ${{ inputs.token }}
labels: ${{ inputs.pr-labels }}
body: |
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.

8
flake.lock generated
View File

@ -2,16 +2,16 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1638263381,
"narHash": "sha256-1rZDxTw74ETuJEjwPfpMgY0sfx8Cv1tRNt3gibol574=",
"lastModified": 1654682581,
"narHash": "sha256-Jb1PQCwKgwdNAp907eR5zPzuxV+kRroA3UIxUxCMJ9s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "7b031d0d99e8cdaf0b70457c0cb33f16c0c958bb",
"rev": "e0169d7a9d324afebf5679551407756c77af8930",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable-small",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}

12
update-flake-lock.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ -n "$TARGETS" ]]; then
inputs=()
for input in $TARGETS; do
inputs+=("--update-input" "$input")
done
nix flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
else
nix flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
fi