-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (83 loc) · 3.21 KB
/
modules.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
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
name: 'Test Selectel Terraform modules'
on:
schedule:
- cron: '0 8 * * 2' # run every Tuesday at 11:00 MSK
workflow_dispatch:
jobs:
setup:
name: 'Test Selectel Terraform modules'
runs-on: self-hosted
env:
terraform_link: https://releases.hashicorp.com/terraform/1.5.5/terraform_1.5.5_linux_amd64.zip
TF_VAR_selectel_domain_name: ${{ secrets.SELECTEL_ID }}
TF_VAR_selectel_user_admin_user: ${{ secrets.SERVICE_USER }}
TF_VAR_selectel_user_admin_password: ${{ secrets.SERVICE_PASSWORD }}
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Setup NodeJS v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Terraform
shell: bash
run: |
curl -o terraform.zip $terraform_link
apt-get install unzip
unzip terraform.zip
chmod 755 terraform
mv terraform /usr/local/bin
# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v3
# with:
# terraform_version: "1.5.5"
# - name: Run Checkov action # suppressed for now because it fails to copy a file inside a self-hosted runner
# uses: bridgecrewio/checkov-action@v12
# with:
# quiet: true
# directory: .
# output_format: cli
# framework: terraform,github_actions
# container_user: 1000
- name: Add .terraformrc
shell: bash
run: |
cat <<EOS >> $HOME/.terraformrc
provider_installation {
network_mirror {
url = "https://tf-proxy.selectel.ru/mirror/v1/"
}
}
EOS
- name: Lint Terraform
run: terraform fmt -diff -check -recursive
- name: Init Terraform
run: >
terraform init -reconfigure
-backend-config="bucket=github-terraform-state"
-backend-config="endpoint=s3.ru-1.storage.selcloud.ru"
-backend-config="key=github-infra-examples.tfstate"
-backend-config="region=ru-1"
-backend-config="skip_region_validation=true"
-backend-config="skip_credentials_validation=true"
-backend-config="access_key=${{ secrets.S3_ACCESS_KEY }}"
-backend-config="secret_key=${{ secrets.S3_SECRET_KEY }}"
- name: Terraform apply
run: terraform apply -auto-approve
- name: Terraform destroy
run: terraform destroy -auto-approve
# - name: Telegram notify if job was failed
# if: ${{ failure() }}
# uses: appleboy/telegram-action@master
# with:
# to: ${{ secrets.TELEGRAM_TO }}
# token: ${{ secrets.TELEGRAM_TOKEN }}
# message: |
# -= GITHUB public repository selectel/selectel-infra-examples =-
# Terraform modules build pipeline was failed
# 🚨 Critical
# Не катится пайпа, необходимо принять меры, возможно внутренние пайпы с terraform так же не будут катиться.
#
# ⚡️Workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
# 🔥 See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}