.github/workflows/docker-publish.yml 1.4 K raw
1
name: Publish Docker image
2
3
on:
4
  push:
5
    branches: [main]
6
    tags: ["v*"]
7
  workflow_dispatch:
8
9
env:
10
  REGISTRY: ghcr.io
11
  IMAGE_NAME: ${{ github.repository_owner }}/feeds-app
12
13
jobs:
14
  build-and-push:
15
    runs-on: ubuntu-latest
16
    permissions:
17
      contents: read
18
      packages: write
19
    steps:
20
      - name: Checkout
21
        uses: actions/checkout@v4
22
23
      - name: Set up Docker Buildx
24
        uses: docker/setup-buildx-action@v3
25
26
      - name: Log in to GHCR
27
        uses: docker/login-action@v3
28
        with:
29
          registry: ${{ env.REGISTRY }}
30
          username: ${{ github.actor }}
31
          password: ${{ secrets.GITHUB_TOKEN }}
32
33
      - name: Extract metadata
34
        id: meta
35
        uses: docker/metadata-action@v5
36
        with:
37
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38
          tags: |
39
            type=ref,event=branch
40
            type=semver,pattern={{version}}
41
            type=semver,pattern={{major}}.{{minor}}
42
            type=sha
43
            type=raw,value=latest,enable={{is_default_branch}}
44
45
      - name: Build and push
46
        uses: docker/build-push-action@v6
47
        with:
48
          context: .
49
          platforms: linux/amd64,linux/arm64
50
          push: true
51
          tags: ${{ steps.meta.outputs.tags }}
52
          labels: ${{ steps.meta.outputs.labels }}
53
          cache-from: type=gha
54
          cache-to: type=gha,mode=max