⬆ Uploaded by uPic #37
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: Sync Files to DogeCloud | |
on: | |
push: | |
branches: | |
- master # 你希望同步的目标分支 | |
workflow_dispatch: # 允许手动触发工作流 | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install required packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y jq curl | |
- name: Sync files to DogeCloud | |
run: | | |
for file in $(find . -type f); do | |
echo "Uploading $file to DogeCloud..." | |
# Prepare the URL and headers | |
url="https://api.dogecloud.com/oss/upload/put.json?bucket=${{ secrets.S3_BUCKET }}&key=$(basename $file)" | |
authorization="TOKEN ${{ secrets.ACCESS_KEY }}:${{ secrets.SECRET_KEY }}" | |
# Make the request | |
response=$(curl -s -X POST "$url" \ | |
-H "Authorization: $authorization" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @"$file") | |
# Output the response | |
echo "Response for $file: $response" | |
# Check if the response contains any errors | |
if [[ $response == *"code":200* ]]; then | |
echo "$file uploaded successfully." | |
else | |
echo "Error uploading $file: $response" | |
fi | |
done | |
env: | |
S3_BUCKET: s-sh-4319-blog-1258813047 | |
ACCESS_KEY: ${{ secrets.ACCESS_KEY }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} |