1
+ name : Publish API Docker image
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ push :
6
+ branches :
7
+ - main
8
+ paths :
9
+ - ' apps/api/**'
10
+
11
+ jobs :
12
+ push_to_registry :
13
+ name : Push Docker image to Docker Hub
14
+ runs-on : ubuntu-latest
15
+ permissions :
16
+ packages : write
17
+ contents : read
18
+ attestations : write
19
+ id-token : write
20
+ steps :
21
+ - name : Check out the repo
22
+ uses : actions/checkout@v4
23
+ with :
24
+ ssh-key : ${{ secrets.SSH_KEY }}
25
+ - uses : oven-sh/setup-bun@v2
26
+ name : Setup bun
27
+ with :
28
+ bun-version : latest
29
+ - uses : fregante/setup-git-user@v2
30
+ name : Setup git user
31
+ - name : Install dependencies
32
+ working-directory : ./apps/api
33
+ run : |
34
+ bun install
35
+ - name : Read version from package.json
36
+ id : get_version
37
+ working-directory : ./apps/api
38
+ run : |
39
+ VERSION=$(jq -r '.version' package.json)
40
+ echo "Current version: $VERSION"
41
+ echo "version=$VERSION" >> $GITHUB_ENV
42
+ - name : Log in to Docker Hub
43
+ uses : docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
44
+ with :
45
+ username : ${{ secrets.DOCKER_USERNAME }}
46
+ password : ${{ secrets.DOCKER_PASSWORD }}
47
+ - name : Extract metadata (tags, labels) for Docker
48
+ id : meta
49
+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
50
+ with :
51
+ images : stormix/deadlock-mods-api
52
+ - name : Set up Docker Buildx
53
+ uses : docker/setup-buildx-action@v3
54
+ - name : Build and push Docker image
55
+ id : push
56
+ uses : docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
57
+ with :
58
+ context : .
59
+ cache-from : type=gha
60
+ cache-to : type=gha,mode=max
61
+ file : ./apps/api/Dockerfile
62
+ push : true
63
+ tags : |
64
+ ${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:${{ env.version }}
65
+ ${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:latest
66
+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments