-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (51 loc) · 1.8 KB
/
prod-pull-request-merge.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
name: Prod PR merge
on:
push:
branches: [ "prod" ]
jobs:
prod-ci:
runs-on: ubuntu-22.04
outputs:
image_tag: ${{ steps.get_image_tag.outputs.IMAGE_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "corretto"
- name: Build with Gradle
run: ./gradlew build
- name: Setup Docker buildx
uses: docker/[email protected]
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_HUB_USERNAME_PROD }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN_PROD }}
- name: Get Image Tag
id: get_image_tag
run: |
IMAGE_TAG=$(git rev-parse --short HEAD)
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Docker Image Build
run: docker build --platform linux/amd64 -t itracker2024/itracker-prod:${{ steps.get_image_tag.outputs.IMAGE_TAG }} -f Dockerfile-prod .
- name: Docker Hub Push
run: docker push itracker2024/itracker-prod:${{ steps.get_image_tag.outputs.IMAGE_TAG }}
prod-cd:
needs: prod-ci
runs-on: [self-hosted, Linux, prod]
steps:
- name: Pull Latest Docker Image
run: |
sudo docker login --username ${{ secrets.DOCKER_HUB_USERNAME_PROD }} --password ${{ secrets.DOCKER_HUB_ACCESS_TOKEN_PROD }}
sudo docker pull itracker2024/itracker-prod:${{ needs.prod-ci.outputs.image_tag }}
- name: Docker Compose
run: |
~/backend/deploy.sh
docker container prune -f
sudo docker image prune -af