-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (52 loc) · 1.94 KB
/
main.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
name: GitOps Pipeline
on:
push:
branches:
- master
env:
DOTNET_VERSION: "8.0"
jobs:
build_and_push_image:
name: Build and push image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code from repository
uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push service Docker image
uses: docker/build-push-action@v2
with:
context: ./service/src/PingPong
push: true
tags: ghcr.io/${{ github.repository }}-service:${{ github.sha }}
- name: Build and push client Docker image
uses: docker/build-push-action@v2
with:
context: ./client/
push: true
tags: ghcr.io/${{ github.repository }}-client:${{ github.sha }}
deploy:
name: Deploy app
needs: build_and_push_image
runs-on: ubuntu-latest
if: success()
steps:
- name: Checkout Code from repository
uses: actions/checkout@v2
- run: |
cd deployment/terraform
terraform init -backend-config "secret_key=$OBJECT_STORAGE_SECRET_KEY" -backend-config "access_key=$OBJECT_STORAGE_ACCESS_KEY"
terraform apply -auto-approve -var "service_account_token=$SERVICE_ACCOUNT_TOKEN" -var "object_storage_secret_key=$OBJECT_STORAGE_SECRET_KEY" -var "object_storage_access_key=$OBJECT_STORAGE_ACCESS_KEY" -var "image_tag=${{ github.sha }}"
env:
OBJECT_STORAGE_SECRET_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_KEY }}
OBJECT_STORAGE_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_ACCESS_KEY }}
SERVICE_ACCOUNT_TOKEN: ${{ secrets.SERVICE_ACCOUNT_TOKEN }}
name: Deploy app