sdk-check #21816
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: sdk-check | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
# Run every 1 hour | |
schedule: | |
- cron: '*/60 * * * *' | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# 指定操作系统类型 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
#初始化python环境 | |
- name: Install Python Tools | |
shell: bash | |
run: | | |
echo ${{ github.repository }} | |
sudo apt-get update | |
sudo apt-get install python3-pip python3-setuptools python3-wheel -y | |
sudo python -m pip install --upgrade pip | |
pip install requests wheel jsonschema wget pyyaml pytest pytest-sugar pytest-html rt-thread-studio | |
#配置ssh及环境变量 | |
- name: Config Github SSH | |
shell: bash | |
if: ${{ github.ref == 'refs/heads/master' }} | |
env: | |
GITEE_PRIVATE_KEY: ${{ secrets.SSH_SECRET_GITEE }} | |
run: | | |
echo ${{ github.repository }} | |
mkdir -p ~/.ssh/ | |
echo "$GITEE_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -t rsa gitee.com >> ~/.ssh/known_hosts | |
#如果是PR直接检查提交的资源是否能正常编译 | |
- name: Generate-Import-Compile-Test | |
shell: bash | |
env: | |
RUN_ID: ${{ github.run_id }} | |
if: ${{ github.event_name == 'pull_request' }} | |
run: | | |
echo ${{ github.repository }} | |
cd ${{ github.workspace }} | |
docker pull realthread/sdk_index:latest | |
docker run -v "`pwd`:/rt-thread/sdk-index" -i realthread/sdk_index:latest bash -c ". /etc/profile && python3 /rt-thread/sdk-index/scripts/check_sdk.py ${{ github.run_id }}" | |
#如果是MERGE直接更新Github-SDKINDEX | |
- name: Update-Github-Sdk-Index | |
shell: bash | |
env: | |
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} | |
if: ${{ github.repository == 'RT-Thread-Studio/sdk-index' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} | |
run: | | |
echo ${{ github.repository }} | |
cd ${{ github.workspace }}/scripts | |
python merge_sdk.py | |
#如果是定时任务直接检查github和gitee并进行同步并更新sdk-index-server | |
- name: Sync-Gitee-Mirror | |
shell: bash | |
env: | |
MIRROR_REG_URL: ${{ secrets.MIRROR_REG_URL }} | |
MIRROR_REG_TOKEN: ${{ secrets.MIRROR_REG_TOKEN }} | |
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} | |
UPDATE_SDK_INDEX_ADDRESS: ${{ secrets.UPDATE_SDK_INDEX_ADDRESS }} | |
UPDATE_SDK_ABROAD_INDEX_ADDRESS: ${{ secrets.UPDATE_SDK_ABROAD_INDEX_ADDRESS }} | |
if: ${{ github.repository == 'RT-Thread-Studio/sdk-index' && github.ref == 'refs/heads/master' &&( github.event_name == 'schedule' || (github.event_name == 'push' && success() ) ) }} | |
run: | | |
echo ${{ github.repository }} | |
cd ${{ github.workspace }}/scripts | |
python sync_gitee.py | |