-
Notifications
You must be signed in to change notification settings - Fork 178
67 lines (64 loc) · 2.72 KB
/
examples.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
name: Examples Checks
# Runs terraform linting and validation commands when examples are modified. Triggered in pull requests and merged commits to master.
on:
push:
branches:
- master
pull_request:
paths:
- .github/workflows/examples.yml
- examples/**
workflow_dispatch: {}
env:
AWS_DEFAULT_REGION: us-west-2
MONGODB_ATLAS_ENABLE_PREVIEW: "true"
jobs:
tf-validate:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
fetch-depth: 0
- run: echo "GO_VERSION=$(cat .go-version)" >> "${GITHUB_ENV}"
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version-file: 'go.mod'
- name: go build
run: go build -o terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 .
- name: override plugin
run: |
# For newer versions
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/"$(go env GOOS)"_"$(go env GOARCH)"/
cp terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/"$(go env GOOS)"_"$(go env GOARCH)"/
- name: replace names of provider for local development
run: grep --include=\*versions.tf -rnl './examples' -e 'source = "mongodb/mongodbatlas"' | xargs sed -i s@mongodb/mongodbatlas@hashicorp/mongodbatlas-dev@g
- name: remove version of provider for local development
run: grep --include=\*versions.tf -rnl './examples' -e 'version =' | xargs sed -i '/^\s*version =/d'
- name: Fix format after substitutions
run: grep --include=\*versions.tf -rnl './examples' -e 'source[[:space:]]\+=' | xargs sed -i 's@\(\([[:space:]]*\)source\)[[:space:]]\+=[[:space:]]*@\2source = @g'
- uses: hashicorp/setup-terraform@97f030cf6dc0b4f5e0da352c7bca9cca34579800
with:
terraform_version: ${{ matrix.terraform_version }}
# Needed to use the output of `terraform validate -json`
terraform_wrapper: false
- name: tf-validate
run: make tools && make tf-validate
tflint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
terraform_version: ["${{vars.TF_VERSION_LATEST}}"]
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
fetch-depth: 0
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
with:
go-version-file: 'go.mod'
- name: tflint
run: make tools && make tflint