-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·110 lines (97 loc) · 3.03 KB
/
check_nomad.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
99
100
101
102
103
104
105
106
107
108
109
110
name: Plan_Nomad
on:
workflow_dispatch:
inputs:
job_environment:
type: choice
description: Job environment prod or dev
required: true
default: prod
options:
- dev
- prod
env:
path_bot: bot_code
image_name: tgwbot
repo: ghcr.io
job_env: dev
ver: 0
dbport: 5432
jobs:
Checkout_repos:
runs-on:
- self-hosted
steps:
- name: Debug env vars
run: echo $GITHUB_RUN_NUMBER
- name: Clean old Docker images
run: docker system prune -af --volumes
- name: Clean env
run: rm -rf *
- name: Checkout current repo
uses: actions/checkout@v3
Rendering_nomad_file:
runs-on:
- self-hosted
needs: [Checkout_repos]
steps:
- name: Debug env vars
run: echo $GITHUB_RUN_NUMBER
- name: Terraform fmt
id: fmt
run: terraform fmt -check
- name: Terraform Init
id: init
run: terraform init
env:
https_proxy: '164.92.180.74:3128'
http_proxy: '164.92.180.74:3128'
- name: Terraform Validate
id: validate
run: terraform validate -no-color
env:
TF_VAR_DOCKER_USERNAME: '${{ secrets.DOCKER_USERNAME }}'
TF_VAR_DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
TF_VAR_IMAGE_NAME: '${{env.image_name}}'
TF_VAR_REPO: '${{env.repo}}'
TF_VAR_VERSION: '${{ env.ver }}'
TF_VAR_JOB_ENV: '${{ env.job_env }}'
TF_VAR_DB_PORT: ${{env.dbport}}
- name: Terraform Plan
id: plan
run: terraform plan -no-color
env:
TF_VAR_DOCKER_USERNAME: '${{ secrets.DOCKER_USERNAME }}'
TF_VAR_DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
TF_VAR_IMAGE_NAME: '${{env.image_name}}'
TF_VAR_REPO: '${{env.repo}}'
TF_VAR_VERSION: '${{ env.ver }}'
TF_VAR_JOB_ENV: '${{ env.job_env }}'
TF_VAR_DB_PORT: ${{env.dbport}}
- name: Terraform Apply
id: apply
run: terraform apply -auto-approve -var VERSION=$GITHUB_RUN_NUMBER
env:
TF_VAR_DOCKER_USERNAME: '${{ secrets.DOCKER_USERNAME }}'
TF_VAR_DOCKER_PASSWORD: '${{ secrets.DOCKER_PASSWORD }}'
TF_VAR_IMAGE_NAME: '${{env.image_name}}'
TF_VAR_REPO: '${{env.repo}}'
TF_VAR_JOB_ENV: '${{ env.job_env }}'
TF_VAR_VERSION: '${{ env.ver }}'
TF_VAR_DB_PORT: ${{env.dbport}}
Nomad_check:
needs: [Rendering_nomad_file]
runs-on:
- self-hosted
steps:
- name: Nomad_validate
run: nomad job validate bot.nomad
- name: Nomad_Plan
id: nomad_plan
run: |
nomad job plan -no-color bot.nomad | tee /dev/stderr | grep 'Job Modify Index:' | awk -F': ' '{ print $2 }'
- name: Save_job_index
run: |
echo "index1=$(nomad job plan -no-color bot.nomad | grep 'Job Modify Index:' | awk -F': ' '{ print $2 }')" >> $GITHUB_ENV
- name: Echo_job_index
run: echo "${{ env.index1 }}"