BeiDou Nightly Workflow #563
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: BeiDou Nightly Workflow | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # 这个 cron 表达式表示每天的 21:00 UTC 触发 | |
| - cron: '0 21 * * *' | |
| env: | |
| GHCR_REGISTRY: ghcr.io | |
| BACKEND_IMAGE: beidou-server | |
| FRONTEND_IMAGE: beidou-ui | |
| concurrency: | |
| group: ${{github.workflow}} - ${{github.ref}} | |
| cancel-in-progress: true | |
| jobs: | |
| Backend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # attestations: write | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| steps: | |
| - name: Prepare environment for current platform | |
| id: prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Set lower case owner name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} | |
| env: | |
| OWNER: '${{ github.repository_owner }}' | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to the Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Log in to the Github Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile-server | |
| platforms: ${{ matrix.platform }} | |
| tags: | | |
| ${{ secrets.DOCKER_USER }}/${{ env.BACKEND_IMAGE }} | |
| ${{ env.GHCR_REGISTRY }}/${{ env.OWNER_LC }}/${{ env.BACKEND_IMAGE }} | |
| cache-from: type=gha,scope=backend-${{ matrix.platform }} | |
| cache-to: type=gha,mode=max,scope=backend-${{ matrix.platform }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| build-args: | | |
| CACHEBUST=${{ github.run_id }} | |
| - name: Export Digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload Digest Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-backend-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| Backend-merge-digest: | |
| runs-on: ubuntu-latest | |
| needs: Backend | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # attestations: write | |
| steps: | |
| - name: Set lower case owner name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} | |
| env: | |
| OWNER: '${{ github.repository_owner }}' | |
| - name: download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-backend-* | |
| merge-multiple: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Log in to the Github Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and pushs | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create \ | |
| -t "${{ secrets.DOCKER_USER }}/${{ env.BACKEND_IMAGE }}:nightly" \ | |
| -t "${{ env.GHCR_REGISTRY }}/${{ env.OWNER_LC }}/${{ env.BACKEND_IMAGE }}:nightly" \ | |
| $(printf '${{ secrets.DOCKER_USER }}/${{ env.BACKEND_IMAGE }}@sha256:%s ' *) | |
| Frontend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # attestations: write | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| platform: | |
| - linux/amd64 | |
| - linux/arm64 | |
| steps: | |
| - name: Prepare environment for current platform | |
| id: prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Set lower case owner name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} | |
| env: | |
| OWNER: '${{ github.repository_owner }}' | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to the Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Log in to the Github Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: Dockerfile-ui | |
| platforms: ${{ matrix.platform }} | |
| tags: | | |
| ${{ secrets.DOCKER_USER }}/${{ env.FRONTEND_IMAGE }} | |
| ${{ env.GHCR_REGISTRY }}/${{ env.OWNER_LC }}/${{ env.FRONTEND_IMAGE }} | |
| cache-from: type=gha,scope=frontend-${{ matrix.platform }} | |
| cache-to: type=gha,mode=max,scope=frontend-${{ matrix.platform }} | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| build-args: | | |
| CACHEBUST=${{ github.run_id }} | |
| - name: Export Digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload Digest Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-frontend-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| Frontend-merge-digest: | |
| runs-on: ubuntu-latest | |
| needs: Frontend | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| # attestations: write | |
| steps: | |
| - name: Set lower case owner name | |
| run: | | |
| echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} | |
| env: | |
| OWNER: '${{ github.repository_owner }}' | |
| - name: download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-frontend-* | |
| merge-multiple: true | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASS }} | |
| - name: Log in to the Github Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and pushs | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create \ | |
| -t "${{ secrets.DOCKER_USER }}/${{ env.FRONTEND_IMAGE }}:nightly" \ | |
| -t "${{ env.GHCR_REGISTRY }}/${{ env.OWNER_LC }}/${{ env.FRONTEND_IMAGE }}:nightly" \ | |
| $(printf '${{ secrets.DOCKER_USER }}/${{ env.FRONTEND_IMAGE }}@sha256:%s ' *) |