-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (96 loc) · 3.63 KB
/
build_deploy.yaml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Build
on:
push:
branches: ["main"] # Add "main" here when ready
jobs:
build:
name: Build and push Primary API Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Tag in env variable
run: |
echo "vatusa/${{ secrets.REPOSITORY_NAME }}" > APP_NAME
echo "$(echo ${{ github.sha }} | cut -c1-7)" > TAG
- name: Build the Docker image
run: docker build . --file ./Dockerfile --tag $(cat APP_NAME):${{ github.sha }}
- name: Tag the image to commit
run: docker tag $(cat APP_NAME):${{ github.sha }} $(cat APP_NAME):$(cat TAG)
- name: Docker Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
- name: Image push
run: docker push $(cat APP_NAME):$(cat TAG)
build-internal:
name: Build and push internal API Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set Tag in env variable
run: |
echo "vatusa/${{ secrets.REPOSITORY_NAME }}" > APP_NAME
echo "$(echo ${{ github.sha }} | cut -c1-7)"-internal > TAG
- name: Build the Docker image
run: docker build . --file ./Dockerfile_internal --tag $(cat APP_NAME):${{ github.sha }}
- name: Tag the image to commit
run: docker tag $(cat APP_NAME):${{ github.sha }} $(cat APP_NAME):$(cat TAG)
- name: Docker Login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
- name: Image push
run: docker push $(cat APP_NAME):$(cat TAG)
deploy-dev:
name: Deploy dev to ArgoCD
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
repository: 'VATUSA/gitops'
path: gitops
token: ${{ secrets.G_TOKEN }}
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2
- name: Update manifests
run: |
cd $GITHUB_WORKSPACE/gitops/overlays/dev
kustomize edit set image vatusa/${{ secrets.REPOSITORY_NAME }}=vatusa/${{ secrets.REPOSITORY_NAME }}:$(echo ${{ github.sha }} | cut -c1-7)
- name: Commit and push changes
run: |
cd $GITHUB_WORKSPACE/gitops
git config --global user.email "[email protected]"
git config --global user.name "VATUSA6"
git add .
git commit -m "Update primary-api image tag to $(echo ${{ github.sha }} | cut -c1-7)"
- name: Push to gitops repo
run: |
cd $GITHUB_WORKSPACE/gitops
git push origin main
# deploy:
# name: Deploy prod to ArgoCD
# runs-on: ubuntu-latest
# needs: deploy-dev
# steps:
# - name: Check out the repo
# uses: actions/checkout@v4
# with:
# repository: 'VATUSA/gitops'
# path: gitops
# token: ${{ secrets.G_TOKEN }}
# - name: Setup Kustomize
# uses: imranismail/setup-kustomize@v2
# - name: Update manifests
# run: |
# cd $GITHUB_WORKSPACE/gitops/overlays/prod
# kustomize edit set image vatusa/${{ secrets.REPOSITORY_NAME }}=vatusa/${{ secrets.REPOSITORY_NAME }}:${{ github.sha }}
# - name: Commit and push changes
# run: |
# cd $GITHUB_WORKSPACE/gitops
# git config --global user.email "[email protected]"
# git config --global user.name "VATUSA6"
# echo ${{ github.sha }}
# git add .
# git commit -m "Update primary-api image tag to ${{ github.sha }}"
# - name: Push to gitops repo
# run: |
# cd $GITHUB_WORKSPACE/gitops
# git push origin main