Sync GitHub To Gitee #7
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: Sync GitHub To Gitee | |
| on: | |
| delete: | |
| release: | |
| types: | |
| - published | |
| - edited | |
| - prereleased | |
| - released | |
| - deleted | |
| - unpublished | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "27 3 * * *" | |
| concurrency: | |
| group: sync-gitee-${{ github.repository }} | |
| cancel-in-progress: false | |
| env: | |
| GITEE_OWNER: ${{ vars.GITEE_OWNER }} | |
| GITEE_REPO: ${{ vars.GITEE_REPO }} | |
| GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }} | |
| jobs: | |
| trigger-gitee-mirror-pull: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate required settings | |
| run: | | |
| set -euo pipefail | |
| test -n "${GITEE_OWNER}" | |
| test -n "${GITEE_REPO}" | |
| test -n "${GITEE_TOKEN}" | |
| - name: Trigger Gitee remote mirror pull | |
| run: | | |
| set -euo pipefail | |
| api="https://gitee.com/api/v5/repos/${GITEE_OWNER}/${GITEE_REPO}/remote_mirror/pull" | |
| tmp="$(mktemp)" | |
| code="$(curl -sS -o "${tmp}" -w "%{http_code}" -X POST "${api}?access_token=${GITEE_TOKEN}")" | |
| echo "Gitee response HTTP ${code}:" | |
| cat "${tmp}" | |
| if [[ "${code}" != 2* ]]; then | |
| echo "Failed to trigger Gitee remote mirror pull. Confirm this repository has Pull mirror configured in Gitee." >&2 | |
| rm -f "${tmp}" | |
| exit 1 | |
| fi | |
| rm -f "${tmp}" |