πΎ Fetch || β« Update NixOS/nixpkgs π¦βοΈ #5312
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: πΎ Fetch || β« Update NixOS/nixpkgs π¦βοΈ | |
| #MAX_RUNTIME: ~ 03 mins | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 */3 * * *" # Every 3 Hrs | |
| jobs: | |
| fetch: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: "main" | |
| filter: "blob:none" #https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/ | |
| - name: Setup ENV | |
| run: | | |
| #presets | |
| set +x ; set +e | |
| #-------------# | |
| sudo apt update -y | |
| sudo apt install bc coreutils curl dos2unix fdupes jq moreutils wget -y | |
| sudo apt-get install apt-transport-https apt-utils ca-certificates coreutils dos2unix gnupg2 jq moreutils p7zip-full rsync software-properties-common texinfo util-linux wget -y 2>/dev/null ; sudo apt-get update -y 2>/dev/null | |
| # Do again, sometimes fails | |
| sudo apt install bc coreutils curl dos2unix fdupes jq moreutils wget -y | |
| sudo apt-get install apt-transport-https apt-utils ca-certificates coreutils dos2unix gnupg2 jq moreutils p7zip-full rsync software-properties-common texinfo util-linux wget -y 2>/dev/null ; sudo apt-get update -y 2>/dev/null | |
| #tmp | |
| SYSTMP="$(dirname $(mktemp -u))" && export SYSTMP="${SYSTMP}" | |
| echo "SYSTMP=${SYSTMP}" >> "${GITHUB_ENV}" | |
| ##User-Agent | |
| USER_AGENT="$(curl -qfsSL 'https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Misc/User-Agents/ua_chrome_macos_latest.txt')" && export USER_AGENT="${USER_AGENT}" | |
| echo "USER_AGENT=${USER_AGENT}" >> "${GITHUB_ENV}" | |
| continue-on-error: true | |
| - name: Install Addons | |
| run: | | |
| #presets | |
| set +x ; set +e | |
| #-------------# | |
| bash <(curl -qfsSL "https://raw.githubusercontent.com/pkgforge/devscripts/refs/heads/main/Linux/install_bins_curl.sh") | |
| #yj | |
| sudo curl -qfsSL "https://bin.pkgforge.dev/$(uname -m)-$(uname -s)/yj" -o "/usr/local/bin/yj" && sudo chmod +x "/usr/local/bin/yj" | |
| continue-on-error: true | |
| - name: Set TZ to (Asia/Kathmandu) | |
| run: | | |
| # Presets | |
| set +x ; set +e | |
| #--------------# | |
| sudo apt-get update -y && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata | |
| sudo ln -fs "/usr/share/zoneinfo/Asia/Kathmandu" "/etc/localtime" | |
| sudo dpkg-reconfigure --frontend noninteractive tzdata | |
| sudo apt-get install apt-utils software-properties-common -y | |
| sudo apt-get update -y | |
| continue-on-error: true | |
| - name: Setup Nix | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| # Create Output Dir | |
| mkdir -p "${GITHUB_WORKSPACE}/main" | |
| #Install nix | |
| curl -qfsSL "https://nixos.org/nix/install" | bash -s -- --no-daemon | |
| source "${HOME}/.nix-profile/etc/profile.d/nix.sh" | |
| nix --version | |
| continue-on-error: true | |
| - name: Fetch || Update NixOS Packages (https://github.com/NixOS/nixpkgs) | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| source "${HOME}/.nix-profile/etc/profile.d/nix.sh" | |
| #JSON | |
| nix search "nixpkgs#" "^" --extra-experimental-features nix-command --extra-experimental-features flakes --json --refresh --quiet | jq . > "${GITHUB_WORKSPACE}/main/nixpkgs.json" | |
| #Convert to YAML | |
| cat "${GITHUB_WORKSPACE}/main/nixpkgs.json" | yj -jy | tee "${GITHUB_WORKSPACE}/main/nixpkgs.yaml" | |
| #TXT | |
| cat "${GITHUB_WORKSPACE}/main/nixpkgs.json" | jq -r 'to_entries[] | "| \(.value.pname) | \(.value.version) | \(.value.description) | \(.key) |"' | sort -u -o "${SYSTMP}/nixpkgs.txt" | |
| continue-on-error: false | |
| - name: Update README.md | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| cd "${GITHUB_WORKSPACE}/main" | |
| echo -e "" > "${GITHUB_WORKSPACE}/main/README.md" | |
| echo '---' >> "${GITHUB_WORKSPACE}/main/README.md" | |
| echo "|Package | Version | Description | Attribute |" >> "${GITHUB_WORKSPACE}/main/README.md" | |
| echo "|--------|---------|-------------|-----------|" >> "${GITHUB_WORKSPACE}/main/README.md" | |
| cat "${SYSTMP}/nixpkgs.txt" >> "${GITHUB_WORKSPACE}/main/README.md" | |
| echo -e "" >> "${GITHUB_WORKSPACE}/main/README.md" | |
| echo '---' >> "${GITHUB_WORKSPACE}/main/README.md" | |
| cat "${GITHUB_WORKSPACE}/main/README.md" > "${GITHUB_WORKSPACE}/main/README.md.txt" | |
| sed 's/[\*\|]//g' "${SYSTMP}/nixpkgs.txt" > "${GITHUB_WORKSPACE}/main/nixpkgs.txt" | |
| continue-on-error: true | |
| - name: Generate index.html --> ("https://nixos-packages.ajam.dev") | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| #https://github.com/oscarmorrison/md-page | |
| cat "${GITHUB_WORKSPACE}/main/.github/style.header" > "${GITHUB_WORKSPACE}/main/index.html" | |
| echo "" >> "${GITHUB_WORKSPACE}/main/index.html" | |
| #cat "${GITHUB_WORKSPACE}/main/README.md" >> "${GITHUB_WORKSPACE}/main/index.html" | |
| sed -n "$(($(grep -n '|Package' "${GITHUB_WORKSPACE}/main/README.md" | cut -d ':' -f 1) - 1)),\$p" "${GITHUB_WORKSPACE}/main/README.md" >> "${GITHUB_WORKSPACE}/main/index.html" | |
| echo "" >> "${GITHUB_WORKSPACE}/main/index.html" | |
| cat "${GITHUB_WORKSPACE}/main/.github/style.footer" >> "${GITHUB_WORKSPACE}/main/index.html" | |
| continue-on-error: true | |
| - name: Get DateTime | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| # Date Time | |
| NEPALI_TIME="$(TZ='Asia/Kathmandu' date +'%Y-%m-%d (%I:%M:%S %p)')" | |
| echo "NEPALI_TIME=${NEPALI_TIME}" >> "${GITHUB_ENV}" | |
| continue-on-error: true | |
| - name: Git Pull | |
| run: | | |
| #Presets | |
| set +x ; set +e | |
| #--------------# | |
| cd "${GITHUB_WORKSPACE}/main" && git pull origin main | |
| continue-on-error: true | |
| #Commit & Push | |
| - uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| repository: ./main | |
| commit_user_name: Azathothas # defaults to "github-actions[bot]" | |
| commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com" | |
| commit_message: "β Update NixOS/nixpkgs βοΈπ¦ <-- ${{ env.NEPALI_TIME }} β" | |
| #push_options: '--force' |