Test OSS Helper #1
This file contains hidden or 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: Test OSS Helper | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| test_type: | |
| description: 'Type of test to run' | |
| required: true | |
| type: choice | |
| options: | |
| - 'basic-upload' | |
| - 'multiple-files' | |
| - 'directory-upload' | |
| - 'advanced-options' | |
| - 'dry-run' | |
| default: 'dry-run' | |
| region: | |
| description: 'OSS Region (e.g., oss-cn-beijing)' | |
| required: false | |
| default: 'oss-cn-beijing' | |
| bucket: | |
| description: 'OSS Bucket Name' | |
| required: false | |
| default: '' | |
| custom_assets: | |
| description: 'Custom assets (optional, for advanced testing)' | |
| required: false | |
| default: '' | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| # Set fallback values using environment variables | |
| OSS_REGION: ${{ inputs.region != '' && inputs.region || secrets.OSS_REGION || 'oss-cn-beijing' }} | |
| OSS_BUCKET: ${{ inputs.bucket != '' && inputs.bucket || secrets.OSS_BUCKET || 'test-bucket' }} | |
| OSS_ACCESS_KEY: ${{ secrets.OSS_ACCESS_KEY || 'test-key' }} | |
| OSS_SECRET_KEY: ${{ secrets.OSS_SECRET_KEY || 'test-secret' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Create test files | |
| run: | | |
| # Create test directory structure | |
| mkdir -p test-files/{docs,images,config} | |
| # Create various test files | |
| echo "# Test README" > test-files/README.md | |
| echo "Test content for documentation" > test-files/docs/guide.md | |
| echo "Configuration file content" > test-files/config/app.json | |
| echo "Binary-like content" > test-files/images/logo.png | |
| # Create a larger file for testing | |
| head -c 1024 /dev/urandom > test-files/large-file.bin | |
| # Create files with special characters | |
| echo "Unicode test 中文测试" > "test-files/unicode-测试.txt" | |
| echo "Spaces in filename" > "test-files/file with spaces.txt" | |
| echo "📁 Created test files:" | |
| find test-files -type f -exec ls -lh {} \; | |
| - name: Test - Dry Run | |
| if: inputs.test_type == 'dry-run' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: 'test-key-id' | |
| secret-key: 'test-key-secret' | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| timeout: 60 | |
| continue-on-error: true | |
| env: | |
| # This will fail but test the action logic | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Test - Basic Upload (Dry Run) | |
| if: inputs.test_type == 'basic-upload' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| timeout: 120 | |
| continue-on-error: true | |
| - name: Test - Multiple Files | |
| if: inputs.test_type == 'multiple-files' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| test-files/docs/guide.md:documentation/guide.md | |
| test-files/config/app.json:config/application.json | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Test - Directory Upload | |
| if: inputs.test_type == 'directory-upload' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/:website/ | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Test - Advanced Options | |
| if: inputs.test_type == 'advanced-options' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: | | |
| test-files/README.md:docs/readme.md | |
| test-files/large-file.bin:files/large.bin | |
| timeout: 300 | |
| max-retries: 5 | |
| enable-gzip: true | |
| public-read: true | |
| headers: '{"Cache-Control":"max-age=3600","Content-Type":"text/html"}' | |
| continue-on-error: true | |
| - name: Test - Custom Assets | |
| if: inputs.custom_assets != '' | |
| uses: ./ | |
| with: | |
| region: ${{ env.OSS_REGION }} | |
| access-key: ${{ env.OSS_ACCESS_KEY }} | |
| secret-key: ${{ env.OSS_SECRET_KEY }} | |
| bucket: ${{ env.OSS_BUCKET }} | |
| assets: ${{ inputs.custom_assets }} | |
| timeout: 180 | |
| continue-on-error: true | |
| - name: Display Results | |
| if: always() | |
| run: | | |
| echo "🧪 Test completed!" | |
| echo "📊 Test type: ${{ inputs.test_type }}" | |
| echo "🌏 Region: ${{ env.OSS_REGION }}" | |
| echo "🪣 Bucket: ${{ env.OSS_BUCKET }}" | |
| if [ -n "${{ inputs.custom_assets }}" ]; then | |
| echo "📋 Custom assets: ${{ inputs.custom_assets }}" | |
| fi | |
| echo "" | |
| echo "💡 To test with real credentials:" | |
| echo "1. Add OSS_ACCESS_KEY, OSS_SECRET_KEY, OSS_REGION, and OSS_BUCKET to repository secrets" | |
| echo "2. Re-run this workflow" | |
| echo "" | |
| echo "🔍 Check the action logs above for detailed results" |