Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Configure nix access token to prevent GitHub rate limiting #9

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: ./
with:
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

test-action-with-version:
runs-on: ubuntu-latest
Expand All @@ -39,6 +40,7 @@ jobs:
with:
devbox-version: 0.5.5
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

test-action-with-cache:
runs-on: ubuntu-latest
Expand All @@ -49,6 +51,7 @@ jobs:
with:
enable-cache: true
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

test-action-with-sha256-checksum:
runs-on: ubuntu-latest
Expand All @@ -61,6 +64,7 @@ jobs:
refresh-cli: true
project-path: 'testdata'
sha256-checksum: 'd5e623c032d38250346301040d51bcdca8e6db051c3688cc452e0dda5d95a070'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"

test-action-with-sha256-checksum-failure:
runs-on: ubuntu-latest
Expand All @@ -75,6 +79,7 @@ jobs:
refresh-cli: true
sha256-checksum: 'bad-sha'
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"
- name: Fail on success
if: steps.install-devbox.outcome == 'success'
run: echo "The SHA check should have failed!" && exit 1
Expand All @@ -91,3 +96,4 @@ jobs:
refresh-cli: true
sha256-checksum: '3c2ce11638e3ffcd55881ec20143c38feeb24069ccdb5edf82b343c168aaca32'
project-path: 'testdata'
disable-nix-access-token: "${{ github.ref != 'refs/heads/main' }}"
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: jetpack-io/devbox-install-action@v0.4.0

- name: Run arbitrary commands
run: devbox shell -- echo "done!"
run: devbox run -- echo "done!"

- name: Run a script called test
run: devbox run test
Expand All @@ -31,13 +31,14 @@ jobs:

### Action Inputs

| Input argument | description | default |
| ---------------- | ------------------------------------------------------------------- | --------------------- |
| project-path | Path to the folder that contains a valid `devbox.json` | repo's root directory |
| enable-cache | Cache the entire Nix store in github based on your `devbox.json` | false |
| refresh-cli | Specify whether the CLI should be redownloaded | false |
| devbox-version | Specify devbox CLI version you want to pin to. Only supports >0.2.2 | latest |
| sha256-checksum | Specify an explicit checksum for the devbox binary | |
| Input argument | description | default |
| ---------------- | ------------------------------------------------------------------------------------- | --------------------- |
| project-path | Path to the folder that contains a valid `devbox.json` | repo's root directory |
| enable-cache | Cache the entire Nix store in github based on your `devbox.json` | false |
| refresh-cli | Specify whether the CLI should be redownloaded | false |
| devbox-version | Specify devbox CLI version you want to pin to. Only supports >0.2.2 | latest |
| sha256-checksum | Specify an explicit checksum for the devbox binary | |
| disable-nix-access-token | Disable configuration of nix access-tokens with the GitHub token used in the workflow | false |

### Example Configuration

Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
default: ''
sha256-checksum: # the expected SHA256 checksum of the devbox binary.
description: 'Specify an explicit checksum for the devbox binary. For extra security on top of the existing checks in the devbox launch script'
disable-nix-access-token: # 'true' or 'false'
description: 'Disable configuration of nix access-tokens with the GitHub token used in the workflow'
default: 'false'

runs:
using: "composite"
Expand Down Expand Up @@ -105,6 +108,13 @@ runs:
fi
sudo mv "$DEVBOX_BINARY" /usr/local/bin/devbox

- name: Configure nix access-tokens
if: inputs.disable-nix-access-token == 'false'
shell: bash
run: |
mkdir -p ~/.config/nix
echo "access-tokens = github.com=${{ github.token }}" >> ~/.config/nix/nix.conf

- name: Install nix and devbox packages
shell: bash
run: |
Expand Down