Karim shoair commited on
Commit
354b388
·
1 Parent(s): 9620812

ops: add workflow to build and push docker images

Browse files
Files changed (1) hide show
  1. .github/workflows/docker-build.yml +67 -0
.github/workflows/docker-build.yml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Push Docker Image
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ tag:
9
+ description: 'Docker image tag'
10
+ required: true
11
+ default: 'latest'
12
+
13
+ env:
14
+ REGISTRY: docker.io
15
+ IMAGE_NAME: ${{ github.repository_owner }}/scrapling
16
+
17
+ jobs:
18
+ build-and-push:
19
+ runs-on: ubuntu-latest
20
+ permissions:
21
+ contents: read
22
+ packages: write
23
+
24
+ steps:
25
+ - name: Checkout repository
26
+ uses: actions/checkout@v4
27
+
28
+ - name: Set up Docker Buildx
29
+ uses: docker/setup-buildx-action@v3
30
+ with:
31
+ platforms: linux/amd64,linux/arm64
32
+
33
+ - name: Log in to Docker Hub
34
+ uses: docker/login-action@v3
35
+ with:
36
+ registry: ${{ env.REGISTRY }}
37
+ username: ${{ secrets.DOCKER_USERNAME }}
38
+ password: ${{ secrets.DOCKER_PASSWORD }}
39
+
40
+ - name: Extract metadata
41
+ id: meta
42
+ uses: docker/metadata-action@v5
43
+ with:
44
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45
+ tags: |
46
+ type=ref,event=branch
47
+ type=ref,event=pr
48
+ type=semver,pattern={{version}}
49
+ type=semver,pattern={{major}}.{{minor}}
50
+ type=semver,pattern={{major}}
51
+ type=raw,value=latest,enable={{is_default_branch}}
52
+
53
+ - name: Build and push Docker image
54
+ uses: docker/build-push-action@v5
55
+ with:
56
+ context: .
57
+ platforms: linux/amd64,linux/arm64
58
+ push: true
59
+ tags: ${{ steps.meta.outputs.tags }}
60
+ labels: ${{ steps.meta.outputs.labels }}
61
+ cache-from: type=gha
62
+ cache-to: type=gha,mode=max
63
+ build-args: |
64
+ BUILDKIT_INLINE_CACHE=1
65
+
66
+ - name: Image digest
67
+ run: echo ${{ steps.build.outputs.digest }}