This commit is contained in:
@@ -12,7 +12,7 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
git init
|
git init
|
||||||
git remote add origin http://gitea:3000/windychen/windyChenUtils.git
|
git remote add origin http://gitea:3000/windychen/windychen-utils.git
|
||||||
git fetch --depth 1 origin ${{ github.sha }}
|
git fetch --depth 1 origin ${{ github.sha }}
|
||||||
git checkout ${{ github.sha }}
|
git checkout ${{ github.sha }}
|
||||||
|
|
||||||
@@ -47,9 +47,12 @@ jobs:
|
|||||||
- name: Publish to Gitea
|
- name: Publish to Gitea
|
||||||
id: publish-gitea
|
id: publish-gitea
|
||||||
run: |
|
run: |
|
||||||
npm config set //gitea:3000/api/packages/windychen/npm/:_authToken ${{ secrets.NPM_GITEA_TOKEN }}
|
npm config set //gitea:3000/api/packages/windychen/npm/:username ${{ secrets.CI_USER }}
|
||||||
|
npm config set //gitea:3000/api/packages/windychen/npm/:_password ${{ secrets.NPM_GITEA_TOKEN }}
|
||||||
|
npm config set //gitea:3000/api/packages/windychen/npm/:email ci@local
|
||||||
|
npm config set //gitea:3000/api/packages/windychen/npm/:always-auth true
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
EXISTS=$(curl -s "http://gitea:3000/api/v1/packages/windychen?q=windychen-utils" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"version\":\"$VERSION\"" || true)
|
EXISTS=$(curl -s "http://gitea:3000/api/v1/packages/windychen?q=windychen-utils" -u "${{ secrets.CI_USER }}:${{ secrets.CI_PASSWORD }}" | grep -c "\"version\":\"$VERSION\"" || true)
|
||||||
if [ "$EXISTS" -gt 0 ]; then
|
if [ "$EXISTS" -gt 0 ]; then
|
||||||
echo "Gitea: version $VERSION already exists, skipping."
|
echo "Gitea: version $VERSION already exists, skipping."
|
||||||
echo "gitea_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
echo "gitea_result=skipped|版本 ${VERSION} 已存在" >> $GITHUB_OUTPUT
|
||||||
@@ -66,11 +69,11 @@ jobs:
|
|||||||
if: always() && steps.publish-gitea.outcome == 'success'
|
if: always() && steps.publish-gitea.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION=$(node -p "require('./package.json').version")
|
||||||
EXISTS=$(curl -s "http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases/tags/v${VERSION}" -H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" | grep -c "\"tag_name\"" || true)
|
EXISTS=$(curl -s "http://gitea:3000/api/v1/repos/windychen/windychen-utils/releases/tags/v${VERSION}" -u "${{ secrets.CI_USER }}:${{ secrets.CI_PASSWORD }}" | grep -c "\"tag_name\"" || true)
|
||||||
if [ "$EXISTS" = "0" ]; then
|
if [ "$EXISTS" = "0" ]; then
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
"http://gitea:3000/api/v1/repos/windychen/windyChenUtils/releases" \
|
"http://gitea:3000/api/v1/repos/windychen/windychen-utils/releases" \
|
||||||
-H "Authorization: token ${{ secrets.NPM_GITEA_TOKEN }}" \
|
-u "${{ secrets.CI_USER }}:${{ secrets.CI_PASSWORD }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"body\":\"## windychen-utils v${VERSION}\n\n- 发布到 Verdaccio\n- 发布到 Gitea Packages\",\"target_commitish\":\"main\"}"
|
-d "{\"tag_name\":\"v${VERSION}\",\"name\":\"v${VERSION}\",\"body\":\"## windychen-utils v${VERSION}\n\n- 发布到 Verdaccio\n- 发布到 Gitea Packages\",\"target_commitish\":\"main\"}"
|
||||||
else
|
else
|
||||||
@@ -119,4 +122,5 @@ jobs:
|
|||||||
|
|
||||||
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \
|
curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"${TITLE}\",\"text\":\"## ${TITLE}\n\n${VERD_LINE}\n${GITEA_LINE}\n\n- 仓库: windychen/windyChenUtils\n- 分支: ${{ github.ref_name }}\n- 提交: ${{ github.sha }}\"}}"
|
-d "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"${TITLE}\",\"text\":\"## ${TITLE}\n\n${VERD_LINE}\n${GITEA_LINE}\n\n- 仓库: windychen/windychen-utils\n- 分支: ${{ github.ref_name }}\n- 提交: ${{ github.sha }}\"}}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user