-
Notifications
You must be signed in to change notification settings - Fork 6
80 lines (77 loc) · 2.67 KB
/
push-api.yml
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
73
74
75
76
77
78
79
80
name: Publish API Docker image
env:
PNPM_VERSION: "9.15.0"
NODE_VERSION: "22.11.0"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'apps/api/**'
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_KEY }}
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache-dependency-path: pnpm-lock.yaml
- uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
working-directory: ./apps/api
run: |
pnpm install
- name: Read version from package.json
id: get_version
working-directory: ./apps/api
run: |
VERSION=$(jq -r '.version' package.json)
echo "Current version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: stormix/deadlock-mods-api
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
file: ./apps/api/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:${{ env.version }}
${{ secrets.DOCKER_USERNAME }}/deadlock-mods-api:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Setup ArgoCD CLI
run: |
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
- name: Synchronize API
run: |
argocd app sync deadlock-mod-manager --auth-token "${{ secrets.ARGOCD_TOKEN }}" --server ${{ secrets.ARGOCD_SERVER }} --grpc-web --resource *:Deployment:deadlock-mod-manager-web --replace --force