slitaz5cn/.github/workflows/main.yml

202 lines
6.3 KiB
YAML
Raw Permalink Normal View History

2021-02-09 00:31:18 +00:00
# This is a basic workflow to help you get started with Actions
name: slitaz-5.0
2021-04-15 03:19:00 +00:00
2021-04-15 03:20:57 +00:00
env:
2021-04-15 03:19:00 +00:00
UPLOAD_RELEASE: true
2021-04-15 08:44:49 +00:00
UPLOAD_artifact: true
2021-04-15 03:19:00 +00:00
TZ: Asia/Shanghai
2021-02-09 00:31:18 +00:00
#on:
# push:
# branches:
# - main
# schedule:
# - cron: 0 20 1 * *
# release:
# types: [published]
2021-04-15 03:19:00 +00:00
#on:
# push:
2021-02-09 00:31:18 +00:00
# Sequence of patterns matched against refs/tags
2021-04-15 03:19:00 +00:00
# tags:
# - '*'
# release:
# types: [published]
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: true
default: 'false'
schedule:
- cron: 0 11 * * 1
2021-02-09 00:31:18 +00:00
jobs:
build:
name: 自动汉化并封装每周官方映像
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Space cleanup
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi `docker images -q`
sudo -E apt-get update
sudo -E apt-get -y install zip unzip genisoimage p7zip-full p7zip-rar
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
2021-04-15 03:19:00 +00:00
sudo timedatectl set-timezone "$TZ"
2021-02-09 00:31:18 +00:00
- name: download iso and unzip iso
run: |
2021-04-15 03:19:00 +00:00
wget http://mirror.slitaz.org/iso/rolling/slitaz-rolling-core64.iso
2021-02-09 00:31:18 +00:00
mkdir iso-old
7z x slitaz-rolling-core64.iso -y -r -o./iso-old
2022-02-15 17:17:33 +00:00
wget -O ./packages/teasiu-5.0.tazpkg https://slitaz.cn/dl/teasiu-5.0.tazpkg
wget -O ./packages/updatetime.txt https://slitaz.cn/dl/rolling/slitaz-rolling-core64-chinese-updatetime.txt
2021-02-09 00:31:18 +00:00
- name: download iso32 and unzip iso32
run: |
2021-04-15 03:19:00 +00:00
wget http://mirror.slitaz.org/iso/rolling/slitaz-rolling-core.iso
2021-02-09 00:31:18 +00:00
mkdir iso-old32
7z x slitaz-rolling-core.iso -y -r -o./iso-old32
2021-04-21 07:34:56 +00:00
- name: download iso64 and unzip iso64 for dockerd
run: |
wget http://mirror.slitaz.org/iso/rolling/slitaz-rolling-core64.iso
mkdir iso-old64
7z x slitaz-rolling-core64.iso -y -r -o./iso-old64
2021-02-09 00:31:18 +00:00
- name: docker build a new rootfs64
run: |
docker build -t newrootfs -f ./dockerfile-rootfs64 .
- name: copy rootfs.gz outside of docker
run: |
docker run --name myrootfs newrootfs
docker cp myrootfs:/tmp/rootfs-new.gz ./iso64/mkiso/rootfs.gz
cd ./iso64
sh iso.sh
cd ../
- name: docker build a new rootfs32
run: |
docker build -t newrootfs32 -f ./dockerfile-rootfs32 .
- name: copy rootfs32.gz outside of docker
run: |
docker run --name myrootfs32 newrootfs32
docker cp myrootfs32:/tmp/rootfs-new.gz ./iso32/mkiso/rootfs.gz
cd ./iso32
sh iso.sh
2021-04-21 07:34:56 +00:00
- name: docker build a new rootfs64d
run: |
docker build -t newrootfs64d -f ./dockerfile-rootfs64d .
- name: copy rootfs64d.gz outside of docker
run: |
docker run --name myrootfs64 newrootfs64d
docker cp myrootfs64:/tmp/rootfs-new.gz ./iso64d/mkiso/rootfs.gz
cd ./iso64d
sh iso.sh
2021-02-09 00:31:18 +00:00
- name: Prepare artifact
run: |
mkdir -p slitaz-artifact
cp -a ./slitaz5.0-rolling-core64-cn.iso slitaz-artifact/
cp -a ./slitaz5.0-rolling-core32-cn.iso slitaz-artifact/
2021-04-21 07:34:56 +00:00
cp -a ./slitaz5.0-rolling-core64-cn-docker.iso slitaz-artifact/
2021-02-09 00:31:18 +00:00
2021-04-15 08:19:10 +00:00
- name: upload to artifact
2021-02-09 00:31:18 +00:00
uses: actions/upload-artifact@v2
2021-04-15 08:19:10 +00:00
if: env.UPLOAD_artifact == 'true' && !cancelled()
2021-02-09 00:31:18 +00:00
with:
name: slitaz5-rolling-core64
path: slitaz-artifact/
2021-04-15 03:19:00 +00:00
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "::set-output name=release_tag::$(date +"%Y.%m.%d-%H%M")"
touch release.txt
2021-04-15 03:54:35 +00:00
echo "# hello slitaz!" > release.txt
2021-04-15 03:19:00 +00:00
echo "::set-output name=status::success"
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
2021-02-09 00:31:18 +00:00
env:
2021-04-15 03:19:00 +00:00
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
2021-02-09 00:31:18 +00:00
2021-04-15 03:54:35 +00:00
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
2021-02-09 00:31:18 +00:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2021-04-15 03:54:35 +00:00
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: slitaz-artifact/*
2021-04-15 08:19:10 +00:00
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 3
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.1.0
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-04-15 03:54:35 +00:00
# - name: Upload Release Asset
# id: upload-release-asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.tag.outputs.upload_url }}
# asset_path: ./slitaz5.0-rolling-core64-cn.iso
# asset_name: slitaz5.0-rolling-core64-cn.iso
# asset_content_type: application/iso
2021-02-09 00:31:18 +00:00
slitaz:
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: slitaz5-rolling-core64
path: slitaz-artifact/
- name: Upload to SourceForge
run: |
echo "$DEPLOY_KEY" > $HOME/deploy_key
cat $HOME/deploy_key
set -ex
chmod 600 $HOME/deploy_key
Localslitaz=`ls -d slitaz-artifact`
Remoteslitaz=teasiu@frs.sourceforge.net:/home/frs/project/slitaz/slitaz5-rolling-core64
rsync -e "ssh -i $HOME/deploy_key -oStrictHostKeyChecking=no -oBatchMode=yes" -va --delete $Localslitaz/*.iso $Remoteslitaz
env:
DEPLOY_KEY: ${{ secrets.TEASIU }}