-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (74 loc) · 2.61 KB
/
prd.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
name: 3. Production deployment
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_NAME: opsta/opsta-linebot
on:
workflow_dispatch:
inputs:
use-latest:
type: boolean
required: true
default: false
description: Automatically pick the latest tag version
version:
type: string
required: false
description: 'Put version to deploy to production'
jobs:
# Commit to Git for ArgoCD
gitops-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get latest tag version
if: ${{ inputs.use-latest }}
id: semver
uses: anothrNick/github-tag-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DRY_RUN: true
DEFAULT_BUMP: none
- name: Set tag version
run: echo "DEPLOY_VERSION=${{ inputs.use-latest && steps.semver.outputs.tag || inputs.version }}" >> "$GITHUB_ENV"
- name: Generate job summary version to deploy
run: |
echo "This GitHub Actions is going to deploy ${{ env.IMAGE_NAME }} to version ${{ env.DEPLOY_VERSION }}" >> $GITHUB_STEP_SUMMARY
- name: Check if container image tag exists
uses: tyriis/[email protected]
id: check-tag
with:
registry: ${{ env.IMAGE_REGISTRY }}
repository: ${{ env.IMAGE_NAME }}
tag: ${{ env.DEPLOY_VERSION }}
- name: Fail if container image tag not exists
if: steps.check-tag.outputs.tag == 'not found'
run: |
echo "::error title=Container image tag not found::Container image tag ${{ env.DEPLOY_VERSION }} does not exist"
exit 1
- name: Update Image Version in Helm Value file
uses: fjogeleit/yaml-update-action@main
with:
valueFile: "iac/helm-values/opsta-line-bot-prd.yaml"
propertyPath: image.tag
value: ${{ env.DEPLOY_VERSION }}
branch: main
message: "Update Image Version to ${{ env.DEPLOY_VERSION }}"
# ArgoCD Sync
gitops-sync:
runs-on: ubuntu-latest
container:
image: quay.io/argoproj/argocd:v2.12.4
env:
ARGOCD_SERVER: ${{ secrets.ARGOCD_SERVER }}
ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_AUTH_TOKEN }}
# run after all of needs are complete (whether skipped or success)
if: ${{ !cancelled() && !failure() }}
needs:
- gitops-commit
steps:
- name: Sync ArgoCD
run: |
argocd app sync demo-opsta-line-bot-prd/opsta-line-bot-prd --project demo
argocd app wait demo-opsta-line-bot-prd/opsta-line-bot-prd --health