Skip to content

Commit

Permalink
Обновление версий Terraform и OpenTofu (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Orlov <[email protected]>
  • Loading branch information
v1km4n and Alexey Orlov authored Dec 13, 2024
1 parent 069520a commit bc566c0
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/modules.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: 'Test Selectel Terraform modules'
name: 'Modules Test Run - Terraform v1.10.2'

on:
schedule:
- cron: '0 8 * * 2' # run every Tuesday at 11:00 MSK
- cron: '0 8 * * 1' # run every Monday at 11:00 MSK
workflow_dispatch:

jobs:
setup:
name: 'Test Selectel Terraform modules'
name: 'Modules Test Run - Terraform v1.10.2'
runs-on: self-hosted
env:
terraform_link: ${{ secrets.TERRAFORM_BINARY }}
terraform_link: ${{ secrets.TERRAFORM_BINARY_LATEST }}
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 }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/opentofu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Test Opentofu Selectel Terraform modules'
name: 'Modules Test Run - OpenTofu Latest'

on:
schedule:
Expand All @@ -7,7 +7,7 @@ on:

jobs:
setup:
name: 'Test Opentofu Selectel Terraform modules'
name: 'Modules Test Run - OpenTofu Latest'
runs-on: self-hosted
env:
TF_VAR_selectel_domain_name: ${{ secrets.SELECTEL_ID }}
Expand All @@ -22,8 +22,6 @@ jobs:

- name: Setup OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: 1.6.2

- name: Add .tofurc
shell: bash
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/tf-pre-bsl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Modules Test Run - Terraform Pre-BSL'

on:
schedule:
- cron: '0 8 * * 3' # run every Wednesday at 11:00 MSK
workflow_dispatch:

jobs:
setup:
name: 'Modules Test Run - Terraform Pre-BSL'
runs-on: self-hosted
env:
terraform_link: ${{ secrets.TERRAFORM_BINARY_PREBSL }}
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 }}
TF_VAR_flavor_name: ${{ secrets.FLAVOR_NAME }}
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
unzip terraform.zip
rm terraform.zip
chmod 755 terraform
mv terraform /usr/local/bin
# - 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 }}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Selectel Terraform Modules Example

| Pipeline Status | Version |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| [![Terraform - Selectel Terraform modules](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml) | [![version](https://img.shields.io/badge/terraform-1.5.5-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.5.5) |
| [![OpenTofu - Selectel Terraform modules](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml) | [![version](https://img.shields.io/badge/opentofu-1.6.2-green.svg)](https://github.com/opentofu/opentofu/releases/tag/v1.6.2) |
| Description | Pipeline Status | Version |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| Terraform v1.10.2 | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/modules.yml) | [![version](https://img.shields.io/badge/Terraform-1.10.2-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.10.2) |
| Terraform Pre-BSL | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/tf-pre-bsl.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/tf-pre-bsl.yml) | [![version](https://img.shields.io/badge/Terraform-1.5.7-green.svg)](https://github.com/hashicorp/terraform/releases/tag/v1.5.7) |
| OpenTofu Latest | [![](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml/badge.svg)](https://github.com/selectel/selectel-infra-examples/actions/workflows/opentofu.yml) | [![version](https://img.shields.io/badge/OpenTofu-Latest-green.svg)](https://github.com/opentofu/opentofu/releases/latest) |

- [Selectel Terraform Modules Example](#selectel-terraform-modules-example)
- [Использование](#использование)
Expand Down

0 comments on commit bc566c0

Please sign in to comment.