feat: add GitHub Actions workflow for uploading files to Vercel Blob #1
Workflow file for this run
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: Upload Files to Vercel Blob | |
| on: [push] | |
| jobs: | |
| upload-static-files: | |
| runs-on: ubuntu-latest | |
| name: Upload static files to Vercel Blob | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Create sample files | |
| run: | | |
| mkdir -p dist | |
| echo "Hello from GitHub Actions!" > dist/hello.txt | |
| echo "Build timestamp: $(date)" > dist/build-info.txt | |
| echo '{"version": "1.0.0", "build": "'$(date -u +%Y%m%d%H%M%S)'"}' > dist/metadata.json | |
| - name: Upload hello.txt to Vercel Blob | |
| uses: ./ | |
| with: | |
| source: "dist/hello.txt" | |
| destination: "uploads/hello.txt" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| - name: Upload build info with timestamp | |
| uses: ./ | |
| with: | |
| source: "dist/build-info.txt" | |
| destination: "builds/build-${{ github.sha }}.txt" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| - name: Upload metadata JSON | |
| uses: ./ | |
| with: | |
| source: "dist/metadata.json" | |
| destination: "metadata/build-${{ github.run_number }}.json" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| upload-build-artifacts: | |
| runs-on: ubuntu-latest | |
| name: Build and upload artifacts | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: | | |
| # Simulate a build process | |
| mkdir -p build | |
| npm run build || echo "No build script found, creating sample build files" | |
| echo "Built application at $(date)" > build/app.txt | |
| echo "Version: ${{ github.sha }}" >> build/app.txt | |
| - name: Upload build artifact | |
| id: upload-build | |
| uses: ./ | |
| with: | |
| source: "build/app.txt" | |
| destination: "releases/${{ github.ref_name }}/app-${{ github.sha }}.txt" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| - name: Display upload result | |
| run: | | |
| echo "Build artifact uploaded successfully!" | |
| echo "URL: ${{ steps.upload-build.outputs.url }}" | |
| conditional-upload: | |
| runs-on: ubuntu-latest | |
| name: Conditional file upload | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.file_to_upload != '' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check if file exists | |
| id: check-file | |
| run: | | |
| if [ -f "${{ github.event.inputs.file_to_upload }}" ]; then | |
| echo "file_exists=true" >> $GITHUB_OUTPUT | |
| echo "File exists: ${{ github.event.inputs.file_to_upload }}" | |
| else | |
| echo "file_exists=false" >> $GITHUB_OUTPUT | |
| echo "File not found: ${{ github.event.inputs.file_to_upload }}" | |
| fi | |
| - name: Upload specified file | |
| if: steps.check-file.outputs.file_exists == 'true' | |
| uses: ./ | |
| with: | |
| source: ${{ github.event.inputs.file_to_upload }} | |
| destination: "manual-uploads/${{ github.event.inputs.file_to_upload }}" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| upload-with-error-handling: | |
| runs-on: ubuntu-latest | |
| name: Upload with error handling | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Create test file | |
| run: | | |
| mkdir -p temp | |
| echo "Test file content" > temp/test.txt | |
| - name: Upload with error handling | |
| id: upload-test | |
| continue-on-error: true | |
| uses: ./ | |
| with: | |
| source: "temp/test.txt" | |
| destination: "tests/test-${{ github.run_id }}.txt" | |
| read-write-token: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | |
| - name: Handle upload result | |
| run: | | |
| if [ "${{ steps.upload-test.outcome }}" == "success" ]; then | |
| echo "✅ Upload successful!" | |
| echo "File URL: ${{ steps.upload-test.outputs.url }}" | |
| else | |
| echo "❌ Upload failed!" | |
| echo "Please check your BLOB_READ_WRITE_TOKEN secret" | |
| fi |