Skip to content

Auto update data files #12

Auto update data files

Auto update data files #12

name: 'Auto update data files'
on:
workflow_dispatch:
schedule:
- cron: '55 9 * * *'
jobs:
auto-update:
runs-on: ubuntu-latest
env:
GIT_SSL_NO_VERIFY: 'true'
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 8192
swap-size-mb: 4096
build-mount-path: '/nix'
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Install nix
uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.AUTOMERGE_TOKEN }}
extra_nix_config: |
experimental-features = nix-command flakes ca-derivations
extra-experimental-features = nix-command flakes ca-derivations
extra-platforms = i686-linux aarch64-linux arm-linux
log-lines = 25
- name: Set nix daemon tmpdir path
run: |
sudo mkdir -p /nix/tmpdir
sudo chown "$(whoami)" /nix/tmpdir
cat > override.conf <<EOF
[Service]
Environment="TMPDIR=/nix/tmpdir"
EOF
sudo mkdir /etc/systemd/system/nix-daemon.service.d/
sudo mv override.conf /etc/systemd/system/nix-daemon.service.d/override.conf
sudo systemctl daemon-reload
sudo systemctl restart nix-daemon
- name: Setup SSH key
run: |
mkdir -p "$HOME/.ssh"
echo "${{ secrets.DEPLOY_KEY }}" > "$HOME/.ssh/id_ed25519"
echo "StrictHostKeyChecking no" > "$HOME/.ssh/config"
chmod -R 500 "$HOME/.ssh"
- name: Build nix packages
run: |
cat > secrets.toml <<EOF
[keys]
github = "${{ secrets.GITHUB_TOKEN }}"
EOF
env TMPDIR=/nix/tmpdir nix run .#update-data
rm -f secrets.toml
- env:
API_TOKEN_GITHUB: ${{ secrets.AUTOMERGE_TOKEN }}
run: |
# https://github.com/cpina/github-action-push-to-another-repository/issues/75
git config --unset-all http.https://github.com/.extraheader
git config --global user.email "xddxdd-bot@users.noreply.github.com"
git config --global user.name "xddxdd-bot"
git add .
if git commit -m "auto: update data files" ; then
git remote remove origin
git remote add origin "https://xddxdd-bot:$API_TOKEN_GITHUB@github.com/xddxdd/nixos-config.git"
git push -u origin master
fi