-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
220 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Sync Package Index | ||
|
||
# Below is the configuration and variables that you need to set up. | ||
# 1. A environment named `ruyi-sync` is required. | ||
# 2. Some variables are required to be set in the environments: | ||
# - GHO_TOKEN: is described in [docs](https://github.com/ruyisdk/support-matrix/blob/main/assets/docs/ruyi_index_updator.md) as GITHUB_TOKEN (rename due to a same name default var in CI env) | ||
# - PACKAGE_INDEX_OWNER: decide where the pr goes: blank defaults to `ruyisdk` | ||
# - SSH_PRIVATE: A private SSH key of the bot account | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
inputs: | ||
makepr: | ||
description: 'Make a PR to sync package index' | ||
required: false | ||
default: 'false' | ||
debuginfo: | ||
description: 'Output Debug' | ||
required: false | ||
default: 'false' | ||
# push: # Uncomment this line to enable push event, but it is not recommended as it may cause unnecessary PRs. Use workflow_dispatch instead. | ||
|
||
jobs: | ||
build: | ||
name: Generate and Upload | ||
runs-on: ubuntu-latest | ||
environment: ruyi-sync | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GHO_TOKEN }} | ||
CACHE_DIR: ~/cache | ||
PACKAGE_INDEX_OWNER: ${{ vars.PACKAGE_INDEX_OWNER }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
cache-dependency-path: '**/requirements*.txt' | ||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE }} | ||
- name: Load Cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/cache | ||
key: ${{ runner.os }}-package-index-sync | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
pip install -r assets/requirements_ruyinv.txt | ||
- name: Run tool to generate and upload | ||
if: ${{ ( github.event_name == 'workflow_dispatch' && inputs.makepr == false ) || github.event_name != 'pull_request' || ( github.event_name == 'pull_request' && github.event.pull_request.merged == false ) }} | ||
run: | | ||
echo "Generate Only" > $RUNNER_TEMP/type.txt | ||
export CI_RUN_ID=${{ github.run_id }} | ||
export CI_RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
python assets/renew_ruyi_index.py -c assets/config.toml -p . -i $RUNNER_TEMP/cache --log $RUNNER_TEMP/log.txt --warn $RUNNER_TEMP/warn.txt | ||
- name: Run tool to generate and upload and PR | ||
if: ${{ ( github.event_name == 'workflow_dispatch' && inputs.makepr == true ) || ( github.event_name == 'pull_request' && github.event.pull_request.merged == true ) }} | ||
run: | | ||
echo "Generate and PR" > $RUNNER_TEMP/type.txt | ||
export CI_RUN_ID=${{ github.run_id }} | ||
export CI_RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
python assets/renew_ruyi_index.py -c assets/config.toml -p . -i $RUNNER_TEMP/cache --log $RUNNER_TEMP/log.txt --warn $RUNNER_TEMP/warn.txt --pr | ||
- name: Output Summary | ||
run: | | ||
echo "# Package Index Sync Report" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "[CI #${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) powered by [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "Type: $(cat $RUNNER_TEMP/type.txt)" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "CI has built on commit [${{ steps.truecommit.outputs.shortid }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ steps.truecommit.outputs.longid }}). The commit message is shown below." >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`text" >> $GITHUB_STEP_SUMMARY | ||
echo "$(git log -1)" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "## Warn Log" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`text" >> $GITHUB_STEP_SUMMARY | ||
cat $RUNNER_TEMP/warn.txt >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "## Build Log" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "<details><summary>Click to expand</summary>" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`text" >> $GITHUB_STEP_SUMMARY | ||
cat $RUNNER_TEMP/log.txt >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "</details>" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
- name: Output Debug Info | ||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debuginfo }} | ||
run: | | ||
echo "## Debug Info" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY | ||
echo "${{ toJSON( github ) }}" >> $GITHUB_STEP_SUMMARY | ||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | ||
echo "" >> $GITHUB_STEP_SUMMARY |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,7 @@ class Systems: | |
'.git', | ||
'.vscode', | ||
'__pycache__', | ||
'~', # ? | ||
] | ||
|
||
def should_exclude(self, path): | ||
|
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
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
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
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