|
| 1 | +# Build & publish the `dlslime-ctrl` image to GitHub Container Registry (GHCR). |
| 2 | +# |
| 3 | +# Triggers: |
| 4 | +# - Push to main / master -> publish `:edge` (and the commit SHA) |
| 5 | +# - Push of a tag like v0.1.2 -> publish `:0.1.2`, `:0.1`, `:latest` |
| 6 | +# - Manual workflow_dispatch -> custom tag via input |
| 7 | +# |
| 8 | +# No external secrets needed — uses the built-in GITHUB_TOKEN for auth. |
| 9 | +# After the first successful run, go to: |
| 10 | +# https://github.com/orgs/DeepLink-org/packages/container/dlslime-ctrl/settings |
| 11 | +# and set the package visibility to "Public" so anonymous `docker pull` works. |
| 12 | + |
| 13 | +name: docker-publish |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: [main, master] |
| 18 | + tags: ["v*"] |
| 19 | + paths: |
| 20 | + - "dlslime-ctrl/**" |
| 21 | + - "docker/**" |
| 22 | + - ".github/workflows/docker-publish.yml" |
| 23 | + workflow_dispatch: |
| 24 | + inputs: |
| 25 | + tag: |
| 26 | + description: "Extra tag to publish (e.g. dev, rc1)" |
| 27 | + required: false |
| 28 | + default: "" |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + packages: write |
| 33 | + |
| 34 | +env: |
| 35 | + REGISTRY: ghcr.io |
| 36 | + # GHCR requires lowercase. ${{ github.repository_owner }} = "DeepLink-org", |
| 37 | + # so we explicitly lower-case it via the `tolower` toy below. |
| 38 | + IMAGE_NAME: deeplink-org/dlslime-ctrl |
| 39 | + |
| 40 | +jobs: |
| 41 | + publish: |
| 42 | + runs-on: ubuntu-24.04 |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v6 |
| 45 | + |
| 46 | + - name: Set up QEMU (for multi-arch) |
| 47 | + uses: docker/setup-qemu-action@v3 |
| 48 | + |
| 49 | + - name: Set up Docker Buildx |
| 50 | + uses: docker/setup-buildx-action@v3 |
| 51 | + |
| 52 | + - name: Log in to GHCR |
| 53 | + uses: docker/login-action@v3 |
| 54 | + with: |
| 55 | + registry: ${{ env.REGISTRY }} |
| 56 | + username: ${{ github.actor }} |
| 57 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + # Generate tags + OCI labels automatically based on the git ref. |
| 60 | + # v1.2.3 -> 1.2.3, 1.2, latest |
| 61 | + # main -> edge |
| 62 | + # any push -> sha-<short> |
| 63 | + - name: Compute image metadata |
| 64 | + id: meta |
| 65 | + uses: docker/metadata-action@v5 |
| 66 | + with: |
| 67 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 68 | + tags: | |
| 69 | + type=semver,pattern={{version}} |
| 70 | + type=semver,pattern={{major}}.{{minor}} |
| 71 | + type=raw,value=edge,enable={{is_default_branch}} |
| 72 | + type=sha,prefix=sha-,format=short |
| 73 | + type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }} |
| 74 | + labels: | |
| 75 | + org.opencontainers.image.title=dlslime-ctrl |
| 76 | + org.opencontainers.image.description=DLSlime control plane server |
| 77 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 78 | + org.opencontainers.image.licenses=MIT |
| 79 | +
|
| 80 | + - name: Build & push (linux/amd64, linux/arm64) |
| 81 | + uses: docker/build-push-action@v6 |
| 82 | + with: |
| 83 | + context: . |
| 84 | + file: docker/ctrl.Dockerfile |
| 85 | + platforms: linux/amd64,linux/arm64 |
| 86 | + push: true |
| 87 | + tags: ${{ steps.meta.outputs.tags }} |
| 88 | + labels: ${{ steps.meta.outputs.labels }} |
| 89 | + cache-from: type=gha |
| 90 | + cache-to: type=gha,mode=max |
| 91 | + |
| 92 | + - name: Print published tags |
| 93 | + run: | |
| 94 | + echo "Published tags:" |
| 95 | + echo "${{ steps.meta.outputs.tags }}" |
0 commit comments