move CI from travis to github action
This commit is contained in:
parent
04ddd0c967
commit
f78ea72084
8 changed files with 132 additions and 129 deletions
37
.github/workflows/update.yml
vendored
Normal file
37
.github/workflows/update.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
name: Update
|
||||
|
||||
on:
|
||||
workflow_dispatch: # manual run
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
# Run at midnight on Sunday (UTC)
|
||||
- cron: "0 0 * * 0"
|
||||
|
||||
jobs:
|
||||
update:
|
||||
name: Update
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- name: Checkout this repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
|
||||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
|
||||
|
||||
- name: Update fonts
|
||||
run: ./update.sh
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
github_deploy_key
|
18
.travis.yml
18
.travis.yml
|
@ -1,18 +0,0 @@
|
|||
language: python
|
||||
git:
|
||||
depth: false
|
||||
before_install:
|
||||
- >-
|
||||
openssl aes-256-cbc
|
||||
-K $encrypted_8ebb1ef83f64_key
|
||||
-iv $encrypted_8ebb1ef83f64_iv
|
||||
-in github_deploy_key.enc
|
||||
-out github_deploy_key
|
||||
-d
|
||||
- chmod 600 github_deploy_key
|
||||
- eval $(ssh-agent -s)
|
||||
- ssh-add github_deploy_key
|
||||
python:
|
||||
- "3.6"
|
||||
script:
|
||||
- ./ci/update-overlay.sh
|
25
README.md
25
README.md
|
@ -1,26 +1,23 @@
|
|||
# Nix Google Fonts Overlay 🎁
|
||||
|
||||
[](https://travis-ci.org/dimitarnestorov/nix-google-fonts-overlay)
|
||||
|
||||
**1523 high-quality fonts packaged for Nix**
|
||||
|
||||
This [Nix overlay](https://nixos.org) contains individual packages for all the
|
||||
fonts from the [Google Fonts project](https://github.com/google/fonts). The
|
||||
packages are automatically generated using
|
||||
[nix-google-fonts-gen](https://github.com/dimitarnestorov/nix-google-fonts-gen) tool.
|
||||
Updated weekly.
|
||||
This [Nix overlay](https://nixos.org) allows you to use fonts in
|
||||
[github.com/google/fonts](https://github.com/google/fonts). Updated weekly.
|
||||
|
||||
## Use in NixOS configuration
|
||||
|
||||
To use fonts from this overlay as a part of NixOS configuration, something like
|
||||
the following can be used:
|
||||
## Examples
|
||||
|
||||
```nix
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
fontsOverlay = import (
|
||||
builtins.fetchTarball https://github.com/dimitarnestorov/nix-google-fonts-overlay/archive/master.tar.gz
|
||||
builtins.fetchTarball "https://github.com/pompydev/nix-google-fonts-overlay/archive/master.tar.gz"
|
||||
);
|
||||
in
|
||||
{
|
||||
|
@ -31,7 +28,5 @@ in
|
|||
google-fonts-exo
|
||||
google-fonts-lobster
|
||||
];
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
main () {
|
||||
if [[ "$TRAVIS" != "true" ]]; then
|
||||
echo "This script is only meant to be used as a part of CI pipeline"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
|
||||
echo "Pull request, ignoring"
|
||||
return 0
|
||||
fi
|
||||
|
||||
clone_fonts &&
|
||||
install_nix_google_fonts_gen &&
|
||||
update_overlay &&
|
||||
push_changes
|
||||
}
|
||||
|
||||
clone_fonts () {
|
||||
echo "Cloning Google Fonts repository"
|
||||
git clone https://github.com/google/fonts.git ~/fonts >/dev/null 2>&1
|
||||
}
|
||||
|
||||
install_nix_google_fonts_gen () {
|
||||
echo "Installing nix-google-fonts-gen"
|
||||
git clone https://github.com/dimitarnestorov/nix-google-fonts-gen.git ~/nix-google-fonts-gen >/dev/null 2>&1 &&
|
||||
pushd ~/nix-google-fonts-gen &&
|
||||
./setup.py install &&
|
||||
popd
|
||||
}
|
||||
|
||||
update_overlay () {
|
||||
echo "Updating overlay contents"
|
||||
rm -rf default.nix pkgs
|
||||
nix-google-fonts-gen ~/fonts .
|
||||
update_readme
|
||||
}
|
||||
|
||||
update_readme () {
|
||||
local font_count
|
||||
echo "Updating README.md"
|
||||
font_count="$(ls pkgs | wc -l)"
|
||||
sed -E -i "s/\\*\\*[[:digit:]]+ high-quality fonts packaged for Nix\\*\\*/\\*\\*$font_count high-quality fonts packaged for Nix\\*\\*/" README.md
|
||||
}
|
||||
|
||||
push_changes () {
|
||||
local message
|
||||
git config --global user.email "travis@travis-ci.org"
|
||||
git config --global user.name "Travis CI"
|
||||
|
||||
if ! git add -A; then
|
||||
echo "Failed to add files"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if git diff-index --quiet HEAD; then
|
||||
echo "No changes since the last commit, exiting"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Committing changes"
|
||||
|
||||
git checkout master
|
||||
|
||||
message="[Travis CI] Automatic update $(date "+%Y-%m-%d") (Build $TRAVIS_BUILD_NUMBER)"
|
||||
|
||||
if ! git commit -m "$message"; then
|
||||
echo "Failed to commit"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Pushing"
|
||||
|
||||
if ! git remote rm origin; then
|
||||
echo "Failed to remove origin"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! git remote add origin "git@github.com:dimitarnestorov/nix-google-fonts-overlay.git"; then
|
||||
echo "Failed to add origin";
|
||||
fi
|
||||
|
||||
if ! git push origin master; then
|
||||
echo "Failed to push"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
description = "Google Fonts";
|
||||
outputs = { self }: {
|
||||
lib = import ./.;
|
||||
};
|
||||
outputs =
|
||||
{ self }:
|
||||
{
|
||||
lib = import ./.;
|
||||
};
|
||||
}
|
||||
|
|
Binary file not shown.
80
update.sh
Executable file
80
update.sh
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
main() {
|
||||
clone_fonts &&
|
||||
install_nix_google_fonts_gen &&
|
||||
# update_overlay &&
|
||||
commit_changes
|
||||
}
|
||||
|
||||
clone_fonts() {
|
||||
echo "Cloning https://github.com/google/fonts..."
|
||||
if [ ! -d ./fonts ]; then
|
||||
git clone https://github.com/google/fonts.git ./fonts --depth 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_nix_google_fonts_gen() {
|
||||
echo "Installing https://github.com/pompydev/nix-google-fonts-gen..."
|
||||
if [ ! -d ./nix-google-fonts-gen ]; then
|
||||
git clone https://github.com/pompydev/nix-google-fonts-gen.git ./nix-google-fonts-gen --depth 1
|
||||
fi
|
||||
|
||||
pushd ./nix-google-fonts-gen &&
|
||||
pip install -r requirements.txt &&
|
||||
./setup.py install &&
|
||||
popd
|
||||
}
|
||||
|
||||
update_overlay() {
|
||||
echo "Updating overlay contents"
|
||||
|
||||
if [ -d ./default.nix ]; then
|
||||
rm -rf default.nix
|
||||
fi
|
||||
|
||||
if [ -d ./pkgs ]; then
|
||||
rm -rf pkgs
|
||||
fi
|
||||
|
||||
nix-google-fonts-gen ./fonts .
|
||||
update_readme
|
||||
}
|
||||
|
||||
update_readme() {
|
||||
local font_count
|
||||
echo "Updating README.md"
|
||||
font_count="$(ls pkgs | wc -l)"
|
||||
sed -E -i "s/\\*\\*[[:digit:]]+ high-quality fonts packaged for Nix\\*\\*/\\*\\*$font_count high-quality fonts packaged for Nix\\*\\*/" README.md
|
||||
}
|
||||
|
||||
commit_changes() {
|
||||
local message
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
|
||||
if ! git add -A; then
|
||||
echo "Failed to add files"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if git diff-index --quiet HEAD; then
|
||||
echo "No changes since the last commit, exiting"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Committing changes"
|
||||
|
||||
git checkout master
|
||||
|
||||
message="Automatic update $(date "+%Y-%m-%d")"
|
||||
|
||||
if ! git commit -m "$message"; then
|
||||
echo "Failed to commit"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue