Simplify action to use git from environment.

This commit is contained in:
Fabian Hauser 2025-03-25 15:12:09 +02:00
parent 2ac1137284
commit 0ac932bfa1

View file

@ -1,34 +1,26 @@
name: 'Initialize CI Environment and Repository for Flake Builds' name: 'Initialize CI Environment and Repository for Flake Builds'
description: 'Initialize a CI environment with nix (and also checkout the repository recursively with LFS)' description: |
Initialize a Nix Flakes CI environment (optionally with LFS).
inputs: inputs:
token: token:
description: 'OAUTH token to access repositories' description: 'OAUTH token to access repositories'
required: false required: false
default: ${{ github.token }} default: ${{ github.token }}
lfs: lfs:
description: Whether to enable lfs. Note that nix flakes don't support LFS currently. description: Whether to enable lfs. Note that nix flake builds don't support LFS currently.
required: false required: false
default: true default: false
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Setup NIX CI Environment
run: |
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
nix profile install nixpkgs#git-lfs nixpkgs#gnused
- name: Checkout Repository - name: Checkout Repository
shell: "nix shell nixpkgs#git-lfs nixpkgs#gnused --command {0}" shell: bash
run: | run: |
if [ "${{ inputs.lfs }}" == "true" ]; then git lfs install; fi if [ "${{ inputs.lfs }}" == "true" ]; then git lfs install; fi
GIT_SERVER=`echo -n "$GITHUB_SERVER_URL" | sed "s%https://%%"` echo -e "machine ${GITHUB_SERVER_URL##https://}\nlogin oauth2\npassword ${{ inputs.token }}" > ~/.netrc
echo -e "machine $GIT_SERVER\nlogin oauth2\npassword ${{ inputs.token }}" > ~/.netrc
# Disable clone protection to pull LFS as well # Disable clone protection to pull LFS as well
GIT_CLONE_PROTECTION_ACTIVE=false git clone --branch $GITHUB_REF_NAME --recurse-submodules $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . GIT_CLONE_PROTECTION_ACTIVE=false git clone --branch $GITHUB_REF_NAME --recurse-submodules $GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
git submodule update --init --recursive git submodule update --init --recursive
- name: Prefetch git submodules in nix store - name: Prefetch git submodules in nix store
shell: "nix shell nixpkgs#nixVersions.nix_2_26 nixpkgs#git-lfs --command {0}"
run: git submodule foreach --recursive 'nix flake prefetch' run: git submodule foreach --recursive 'nix flake prefetch'