@@ -2,38 +2,95 @@ name: Deploy Images to GHCR
22
33env :
44 DOTNET_VERSION : ' 6.0.x'
5+ REGISTRY : ghcr.io
6+ API_IMAGE_NAME : revokslab/codecrawl-api
7+ WORKER_IMAGE_NAME : revokslab/codecrawl-worker
58
69on :
710 push :
811 branches :
912 - main
1013 paths :
1114 - apps/api/**
15+ - packages/common/**
16+ - infra/docker/**
17+ - package.json
18+ - bun.lock
1219 workflow_dispatch :
1320
1421jobs :
15- push-app-image :
16- permissions :
17- contents : read
18- packages : write
19- attestations : write
20- id-token : write
21- runs-on : ubuntu-latest
22- defaults :
23- run :
24- working-directory : ' ./apps/api'
25- steps :
26- - name : ' Checkout GitHub Action'
27- uses : actions/checkout@main
28-
29- - name : ' Login to GitHub Container Registry'
30- uses : docker/login-action@v1
31- with :
32- registry : ghcr.io
33- username : ${{github.actor}}
34- password : ${{secrets.GITHUB_TOKEN}}
35-
36- - name : ' Build Inventory Image'
37- run : |
38- docker build . --tag ghcr.io/revokslab/codecrawl:latest
39- docker push ghcr.io/revokslab/codecrawl:latest
22+ build-and-push :
23+ name : Build and Push Images
24+ runs-on : ubuntu-latest
25+ permissions :
26+ contents : read
27+ packages : write
28+
29+ outputs :
30+ api_image : ${{ steps.meta-api.outputs.tags }}
31+ worker_image : ${{ steps.meta-worker.outputs.tags }}
32+ version : ${{ steps.version.outputs.version }}
33+
34+ steps :
35+ - name : Checkout code
36+ uses : actions/checkout@v4
37+
38+ - name : Generate version
39+ id : version
40+ run : echo "version=$(date +'%Y%m%d%H%M%S')-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
41+
42+ - name : Set up Docker Buildx
43+ uses : docker/setup-buildx-action@v3
44+
45+ - name : Log in to Container Registry
46+ uses : docker/login-action@v3
47+ with :
48+ registry : ${{ env.REGISTRY }}
49+ username : ${{ github.actor }}
50+ password : ${{ secrets.GITHUB_TOKEN }}
51+
52+ - name : Extract metadata for API
53+ id : meta-api
54+ uses : docker/metadata-action@v5
55+ with :
56+ images : ${{ env.REGISTRY }}/${{ env.API_IMAGE_NAME }}
57+ tags : |
58+ type=ref,event=branch
59+ type=sha,prefix=
60+ type=raw,value=${{ steps.version.outputs.version }}
61+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
62+
63+ - name : Extract metadata for Worker
64+ id : meta-worker
65+ uses : docker/metadata-action@v5
66+ with :
67+ images : ${{ env.REGISTRY }}/${{ env.WORKER_IMAGE_NAME }}
68+ tags : |
69+ type=ref,event=branch
70+ type=sha,prefix=
71+ type=raw,value=${{ steps.version.outputs.version }}
72+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
73+
74+ - name : Build and push API image
75+ uses : docker/build-push-action@v6
76+ with :
77+ context : .
78+ file : ./infra/docker/api.Dockerfile
79+ push : true
80+ tags : ${{ steps.meta-api.outputs.tags }}
81+ labels : ${{ steps.meta-api.outputs.labels }}
82+ cache-from : type=gha
83+ cache-to : type=gha,mode=max
84+ platforms : linux/amd64,linux/arm64
85+
86+ - name : Build and push Worker image
87+ uses : docker/build-push-action@v6
88+ with :
89+ context : .
90+ file : ./infra/docker/worker.Dockerfile
91+ push : true
92+ tags : ${{ steps.meta-worker.outputs.tags }}
93+ labels : ${{ steps.meta-worker.outputs.labels }}
94+ cache-from : type=gha
95+ cache-to : type=gha,mode=max
96+ platforms : linux/amd64,linux/arm64
0 commit comments