|
| 1 | +name: Archive Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Target Version' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + archive: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout current repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Git |
| 23 | + run: | |
| 24 | + git config --global user.name "ng-zorro-bot" |
| 25 | + git config --global user.email "ng-zorro-bot@users.noreply.github.com" |
| 26 | + |
| 27 | + - name: Clone ng-zorro.github.io repository |
| 28 | + run: | |
| 29 | + git clone https://github.com/NG-ZORRO/ng-zorro.github.io.git --depth=1 temp-repo |
| 30 | + cd temp-repo |
| 31 | + echo "Cloned repository contents:" |
| 32 | + ls -la |
| 33 | + |
| 34 | + - name: Remove issue-helper and version folders and hidden files |
| 35 | + run: | |
| 36 | + cd temp-repo |
| 37 | + echo "Removing issue-helper and version folders..." |
| 38 | + rm -rf issue-helper |
| 39 | + rm -rf version |
| 40 | + echo "Removing all hidden files (starting with .)..." |
| 41 | + rm -rf .* |
| 42 | + echo "Remaining contents after removal:" |
| 43 | + ls -la |
| 44 | + |
| 45 | + - name: Create version directory |
| 46 | + run: | |
| 47 | + mkdir -p version/${{ github.event.inputs.version }} |
| 48 | + echo "Created directory: version/${{ github.event.inputs.version }}" |
| 49 | + |
| 50 | + - name: Move files to version directory |
| 51 | + run: | |
| 52 | + cd temp-repo |
| 53 | + find . -maxdepth 1 -type f -exec mv {} ../version/${{ github.event.inputs.version }}/ \; |
| 54 | + find . -maxdepth 1 -type d ! -name '.' ! -name '..' ! -name '.git' -exec mv {} ../version/${{ github.event.inputs.version }}/ \; |
| 55 | + cd .. |
| 56 | + echo "Files moved to version/${{ github.event.inputs.version }}:" |
| 57 | + ls -la version/${{ github.event.inputs.version }}/ |
| 58 | + |
| 59 | + - name: Clean up temporary repository |
| 60 | + run: | |
| 61 | + rm -rf temp-repo |
| 62 | + |
| 63 | + - name: Commit and push changes |
| 64 | + run: | |
| 65 | + git add version/${{ github.event.inputs.version }}/ |
| 66 | + if git diff --staged --quiet; then |
| 67 | + echo "No changes to commit" |
| 68 | + else |
| 69 | + git commit -m "chore: archive version ${{ github.event.inputs.version }}" |
| 70 | + git push origin ${{ github.ref_name }} |
| 71 | + echo "Successfully archived version ${{ github.event.inputs.version }}" |
| 72 | + fi |
0 commit comments