2023-05-17 10:32:49 +00:00
|
|
|
name: Debian Cache
|
2023-05-12 00:39:50 +00:00
|
|
|
|
|
|
|
on:
|
2023-05-12 01:25:05 +00:00
|
|
|
workflow_dispatch:
|
2023-05-12 00:39:50 +00:00
|
|
|
schedule:
|
2023-05-16 19:44:15 +00:00
|
|
|
- cron: '0 0 * * *'
|
2023-05-12 09:12:18 +00:00
|
|
|
push:
|
|
|
|
paths:
|
|
|
|
- '.github/workflows/debian-cache.yml'
|
2023-05-14 11:06:54 +00:00
|
|
|
- 'distro/debian/snapshot/**'
|
|
|
|
- 'distro/debian/cache.go'
|
|
|
|
- 'distro/debian/kernel.go'
|
2023-05-12 00:39:50 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-05-15 14:21:49 +00:00
|
|
|
debian-kernel-metadata-cache:
|
2023-05-17 10:32:49 +00:00
|
|
|
name: Metadata
|
2023-05-12 00:39:50 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: go build
|
|
|
|
|
|
|
|
- name: Cache
|
2023-05-15 12:16:55 +00:00
|
|
|
run: ./out-of-tree --log-level=trace distro debian cache --refetch=0
|
2023-05-12 07:53:23 +00:00
|
|
|
|
|
|
|
- name: Install s3cmd
|
|
|
|
run: sudo apt install s3cmd
|
|
|
|
|
2023-05-12 00:39:50 +00:00
|
|
|
- name: Archive cache
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: debian-cache
|
2023-05-15 12:07:28 +00:00
|
|
|
path: ~/.out-of-tree/debian.cache
|
2023-05-15 10:35:07 +00:00
|
|
|
|
2023-05-12 00:39:50 +00:00
|
|
|
- name: Archive logs
|
2023-05-12 07:59:58 +00:00
|
|
|
if: always()
|
2023-05-12 00:39:50 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: debian-cache-logs
|
2023-05-15 12:07:28 +00:00
|
|
|
path: ~/.out-of-tree/logs
|
|
|
|
|
|
|
|
- name: Upload cache
|
|
|
|
run: s3cmd put --acl-public ~/.out-of-tree/debian.cache s3://out-of-tree/1.0.0/ --host=fra1.digitaloceanspaces.com --host-bucket='%(bucket)s.fra1.digitaloceanspaces.com' --access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }} --secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
|
2023-05-15 14:21:49 +00:00
|
|
|
|
|
|
|
debian-kernel-packages-mirror:
|
2023-05-17 10:32:49 +00:00
|
|
|
name: Packages
|
2023-05-16 08:04:26 +00:00
|
|
|
needs: debian-kernel-metadata-cache
|
2023-05-15 14:21:49 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: go build
|
|
|
|
|
|
|
|
- name: Install s3cmd
|
|
|
|
run: sudo apt install s3cmd
|
|
|
|
|
|
|
|
- name: Mirror deb packages
|
|
|
|
shell: python
|
|
|
|
run: |
|
|
|
|
import os
|
|
|
|
import logging
|
2023-05-16 07:52:00 +00:00
|
|
|
import time
|
|
|
|
import datetime
|
2023-05-15 14:21:49 +00:00
|
|
|
|
|
|
|
from subprocess import getstatusoutput
|
|
|
|
|
|
|
|
def get_kernels() -> bool:
|
|
|
|
status, output = getstatusoutput(
|
2023-05-17 09:59:31 +00:00
|
|
|
"./out-of-tree distro debian fetch --max=16"
|
2023-05-15 14:21:49 +00:00
|
|
|
)
|
|
|
|
logging.info(output)
|
|
|
|
return status == 0
|
|
|
|
|
|
|
|
def upload(f: str) -> bool:
|
|
|
|
status, output = getstatusoutput(
|
|
|
|
"s3cmd "
|
|
|
|
"--host=fra1.digitaloceanspaces.com "
|
|
|
|
"--host-bucket='%(bucket)s.fra1.digitaloceanspaces.com' "
|
|
|
|
"--access_key=${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }} "
|
|
|
|
"--secret_key=${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }} "
|
|
|
|
f"put --acl-public {f} "
|
|
|
|
"s3://out-of-tree/1.0.0/packages/debian/"
|
|
|
|
)
|
|
|
|
logging.info(output)
|
|
|
|
return status == 0
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.NOTSET)
|
|
|
|
|
|
|
|
uploaded = []
|
|
|
|
|
2023-05-16 14:14:24 +00:00
|
|
|
timeout = time.time() + datetime.timedelta(hours=2).seconds
|
2023-05-16 07:52:00 +00:00
|
|
|
|
|
|
|
while get_kernels() and time.time() < timeout:
|
2023-05-15 14:21:49 +00:00
|
|
|
for f in os.listdir():
|
|
|
|
if not f.endswith('.deb'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if f in uploaded:
|
|
|
|
continue
|
|
|
|
|
|
|
|
logging.info(f)
|
|
|
|
|
|
|
|
ok = upload(f)
|
|
|
|
if ok:
|
|
|
|
uploaded += [f]
|
2023-05-15 14:25:41 +00:00
|
|
|
|
|
|
|
- name: Archive logs
|
|
|
|
if: always()
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: debian-cache-logs
|
|
|
|
path: ~/.out-of-tree/logs
|