-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add mirrorchyan uploading (#307)
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: mirrorchyan | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Version Name | ||
id: version_name | ||
run: | | ||
is_release=${{ startsWith(github.ref, 'refs/tags/v') }} | ||
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true) | ||
if [[ $tag != v* ]]; then | ||
tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]') | ||
if [[ $tag != v* ]]; then | ||
tag="v0.0.0" | ||
fi | ||
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)") | ||
fi | ||
if ! $($is_release) ; then | ||
prefix=${tag%-*-*} | ||
suffix=${tag#$prefix-} | ||
tag="$prefix-ci.$suffix" | ||
fi | ||
echo version=$tag | tee -a $GITHUB_OUTPUT | ||
- name: Zip | ||
id: zip | ||
run: | | ||
mkdir MirrorChyan | ||
zip -r MirrorChyan/${{ github.event.repository.name }}.zip assets/resource assets/interface.json | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: MirrorChyan | ||
path: MirrorChyan | ||
|
||
- name: Upload to MirrorChyan | ||
run: | | ||
curl --location --request POST 'https://mirrorc.top/api/resources/${{ github.event.repository.name }}/versions' \ | ||
--header 'Authorization:${{ secrets.MirrorChyanUploadToken }}' \ | ||
--form 'name="${{ steps.version_name.outputs.version }}"' \ | ||
--form 'file=@"MirrorChyan/${{ github.event.repository.name }}.zip"' |