update crates-sync (#2173) #2
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: Crates Sync deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".github/workflows/crates-sync-deploy.yml" | |
| - "scripts/crates-sync/**" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| REPOSITORY: mega/crates-sync | |
| IMAGE_TAG: latest | |
| HARBOR_REGISTRY: registry.xuanwu.openatom.cn | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Login to Harbor | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.HARBOR_REGISTRY }} | |
| username: ${{ secrets.HARBOR_USERNAME }} | |
| password: ${{ secrets.HARBOR_PASSWORD }} | |
| - name: Build, tag, and push docker image to Harbor | |
| run: | | |
| set -euo pipefail | |
| HARBOR_IMAGE_BASE="${{ env.HARBOR_REGISTRY }}/${{ env.REPOSITORY }}" | |
| IMAGE_TAG="${{ env.IMAGE_TAG }}" | |
| SHORT_SHA="${GITHUB_SHA:0:7}" | |
| docker build \ | |
| -f scripts/crates-sync/Dockerfile \ | |
| -t "$HARBOR_IMAGE_BASE:$IMAGE_TAG" \ | |
| -t "$HARBOR_IMAGE_BASE:$SHORT_SHA" \ | |
| scripts/crates-sync | |
| docker push "$HARBOR_IMAGE_BASE:$IMAGE_TAG" | |
| docker push "$HARBOR_IMAGE_BASE:$SHORT_SHA" |