actions-nix-init/action.yml

31 lines
1.3 KiB
YAML
Raw Normal View History

2024-09-28 21:38:09 +02:00
name: 'Initialize CI Environment and Repository'
description: 'Initialize a CI environment with nix (and also checkout the repository recursively with LFS)'
2024-09-29 13:36:20 +02:00
inputs:
token:
description: 'OAUTH token to access repositories'
required: false
default: ${{ github.token }}
2024-09-29 17:01:50 +02:00
lfs:
description: 'Whether to enable lfs'
required: false
default: true
2024-09-28 21:38:09 +02:00
runs:
using: "composite"
steps:
- name: Setup NIX CI Environment
run: |
2024-12-10 15:52:44 +01:00
mkdir -p ~/.config/nix
echo "substituters = https://nixpkgs-cache.qo.is?priority=39" >> ~/.config/nix/nix.conf
echo "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" >> ~/.config/nix/nix.conf
2024-10-03 13:33:26 +02:00
nix profile install nixpkgs#git-lfs nixpkgs#gnused
2024-09-28 21:38:09 +02:00
2024-09-29 17:01:50 +02:00
- name: Checkout Repository
shell: "nix shell nixpkgs#git-lfs nixpkgs#gnused --command {0}"
run: |
2024-10-03 11:50:04 +02:00
if [ "${{ inputs.lfs }}" == "true" ]; then git lfs install; fi
2024-09-29 13:36:20 +02:00
GIT_SERVER=`echo -n "$GITHUB_SERVER_URL" | sed "s%https://%%"`
echo -e "machine $GIT_SERVER\nlogin oauth2\npassword ${{ inputs.token }}" > ~/.netrc
2024-09-28 21:38:09 +02:00
# Disable clone protection to pull LFS as well
2024-09-29 13:36:20 +02:00
GIT_CLONE_PROTECTION_ACTIVE=false git clone --branch $GITHUB_REF_NAME --recurse-submodules $GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
git submodule update --init