Skip to content

Commit

Permalink
test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyangliu committed Jul 12, 2024
1 parent cfe9fe5 commit d5d75d7
Showing 1 changed file with 25 additions and 33 deletions.
58 changes: 25 additions & 33 deletions .github/workflows/sync_release_to_gitee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
});
const assets = JSON.stringify(response.data.assets);
core.setOutput('assets', assets);
core.setOutput('tag_name', response.data.tag_name);
core.setOutput('name', response.data.name);
core.setOutput('body', response.data.body);
- name: Download release assets
run: |
Expand All @@ -32,36 +35,25 @@ jobs:
wget -q $url -P ./downloads
done
- name: Create release on Gitee
env:
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
run: |
RELEASE_TAG=$(git describe --tags --abbrev=0)
RELEASE_NAME=$(git tag -l --format='%(tag)' --contains ${RELEASE_TAG})
RELEASE_BODY=$(git for-each-ref refs/tags/${RELEASE_TAG} --format='%(contents)')
# Create release on Gitee
RESPONSE=$(curl -X POST -H "Content-Type: application/json" \
-H "Authorization: token ${GITEE_TOKEN}" \
-d '{
"access_token": "'${GITEE_TOKEN}'",
"tag_name": "'${RELEASE_TAG}'",
"target_commitish": "main",
"name": "'${RELEASE_NAME}'",
"body": "'${RELEASE_BODY}'",
"draft": false,
"prerelease": false
}' \
https://gitee.com/api/v5/repos/openblockcc/external-resources-v3/releases)
RELEASE_ID=$(echo $RESPONSE | jq -r '.id')
# Upload assets to Gitee
for FILE in $(ls ./downloads); do
if [ -f "$FILE" ]; then
curl -X POST -H "Authorization: token ${GITEE_TOKEN}" \
-F "access_token=${GITEE_TOKEN}" \
-F "file=@${FILE}" \
https://gitee.com/api/v5/repos/openblockcc/external-resources-v3/releases/${RELEASE_ID}/assets?name=${FILE}
fi
done
- name: Create Gitee Release
uses: actions/github-script@v6
with:
script: |
const axios = require('axios');
const releaseData = {
access_token: ${{ secrets.GITEE_TOKEN }},
tag_name: ${{ steps.get_release_info.outputs.tag_name }},
name: ${{ steps.get_release_info.outputs.name }},
body: ${{ steps.get_release_info.outputs.body }},
draft: false,
prerelease: false
};
axios.post('https://gitee.com/api/v5/repos/openblockcc/external-resources-v3/releases', releaseData)
.then(response => {
console.log('Gitee release created successfully:', response.data);
})
.catch(error => {
console.error('Error creating Gitee release:', error);
core.setFailed(error.message);
});

0 comments on commit d5d75d7

Please sign in to comment.