Skip to content

Sync

Sync #25030

Workflow file for this run

name: Sync
on:
schedule: # execute every 1 hours
- cron: "0 */1 * * *"
jobs:
build:
if: github.repository == 'xmake-io/xmake-repo' # only runs on root repository
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
- name: Installation
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install -y gh unzip zip
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
git config --global user.email "waruqi@gmail.com"
git config --global user.name "ruki"
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa # optional
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Install SSH key (OSC)
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY_OSC }}
name: id_ed25519 # optional
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Update
run: |
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
xmake l -vD ./scripts/sync.lua
xmake l -vD ./scripts/automerge.lua
- name: Build and publish repology_packages_index.json
run: |
set -e
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
# 1. Generate the manifest (writes dist/repology_packages_index.json).
xmake l scripts/build_index.lua
# 2. Sanity-check the output before publishing.
test -s dist/repology_packages_index.json
python3 -c "import json,sys; d=json.load(open('dist/repology_packages_index.json')); assert d['count']>1000, 'too few packages: %d' % d['count']"
# 3. Publish to gh-pages via SSH (SSH key was installed above).
rm -rf gh-pages-work
git clone git@github.com:xmake-io/xmake-repo.git gh-pages-work
cd gh-pages-work
git checkout gh-pages 2>/dev/null || git checkout --orphan gh-pages
git rm -rf . 2>/dev/null || true
cp ../dist/repology_packages_index.json .
git add repology_packages_index.json
git diff-index --quiet HEAD -- && echo "no changes to publish" || {
git commit -m "autoupdate repology_packages_index.json"
git push origin gh-pages
}