aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/docker-build-push.yaml
blob: 15eae52e0e0b4146a1e3b634f212fcb97860a8e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Build and Push Docker Image

# Define when this workflow will run
on:
  push:
    branches:
      - master  # Trigger on pushes to master branch
    tags:
      - '[0-9]+.[0-9]+.[0-9]+'  # Trigger on semantic version tags
    paths-ignore:
      - 'Cargo.lock'
      - 'LICENSE'
      - 'README.md'
      - 'docker-compose.yml'
  workflow_dispatch:  # Allow manual triggering of the workflow

# Define environment variables used throughout the workflow
env:
  REGISTRY: quay.io
  IMAGE_NAME: invidious/inv-sig-helper

jobs:
  build-and-push:
    runs-on: ubuntu-latest

    steps:
      # Step 1: Check out the repository code
      - name: Checkout code
        uses: actions/checkout@v3

      # Step 2: Set up QEMU for multi-architecture builds
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      # Step 3: Set up Docker Buildx for enhanced build capabilities
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      # Step 4: Authenticate with Quay.io registry
      - name: Log in to Quay.io
        uses: docker/login-action@v2
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.QUAY_USERNAME }}
          password: ${{ secrets.QUAY_PASSWORD }}

      # Step 5: Extract metadata for Docker image tagging and labeling
      - name: Extract metadata for Docker
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          # Define tagging strategy
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
            type=sha,prefix={{branch}}-
          # Define labels
          labels: |
            quay.expires-after=12w

      # Step 6: Build and push the Docker image
      - name: Build and push Docker image
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64  # Build for multiple architectures
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}