Download .github/workflows/docker.yml from wudidepan/Anki: direct link, hf CLI and curl.
- Browser
- Download file 3.17 kB
-
https://huggingface.co/spaces/wudidepan/Anki/resolve/main/.github/workflows/docker.yml
- Command line
-
hf download hf://spaces/wudidepan/Anki/.github/workflows/docker.yml
-
curl -L -o docker.yml https://huggingface.co/spaces/wudidepan/Anki/resolve/main/.github/workflows/docker.yml
3.17 kB
| name: Build and push anki-sync-server Docker image | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "11 0 * * *" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| get-latest-tag: | |
| name: Get latest tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Anki | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| repository: ankitects/anki | |
| - name: Get Anki latest tag | |
| id: tag | |
| run: echo "tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> "$GITHUB_OUTPUT" | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| fetch-depth: 0 | |
| - name: Get my latest tag | |
| id: mytag | |
| run: echo "mytag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> "$GITHUB_OUTPUT" | |
| - name: Add tag | |
| id: addtag | |
| if: steps.tag.outputs.tag != steps.mytag.outputs.mytag | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git tag ${{ steps.tag.outputs.tag }} | |
| git push origin --tags | |
| echo "addtag=true" >> "$GITHUB_OUTPUT" | |
| outputs: | |
| tag: ${{ steps.tag.outputs.tag }} | |
| addtag: ${{ steps.addtag.outputs.addtag }} | |
| build-docker-image: | |
| needs: get-latest-tag | |
| if: needs.get-latest-tag.outputs.addtag == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.get-latest-tag.outputs.tag }} | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| # list of Docker images to use as base name for tags | |
| images: | | |
| ${{ secrets.DOCKER_USERNAME }}/anki-sync-server | |
| ghcr.io/${{ github.repository_owner }}/anki-sync-server | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=${{ needs.get-latest-tag.outputs.tag }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GH_PAT }} | |
| #- name: Get tag | |
| # id: tag | |
| # uses: devops-actions/action-get-tag@v1.0.1 | |
| # with: | |
| # strip_v: true # Optional: Remove 'v' character from version | |
| - name: Build and push Docker images to ghcr.io and DockerHub | |
| uses: docker/build-push-action@v5 | |
| with: | |
| build-args: | | |
| ANKI_VERSION=${{ needs.get-latest-tag.outputs.tag }} | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |