Created
April 26, 2020 20:18
-
-
Save pascalwhoop/600d2c66687f37a9b09ac337cc30663d to your computer and use it in GitHub Desktop.
gcp foundation github actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Apply Terraform' | |
on: | |
push: | |
branches: | |
- master | |
env: | |
tf_version: 'latest' | |
GOOGLE_CREDENTIALS: ${{secrets.GOOGLE_CREDENTIALS}} | |
jobs: | |
terraform: | |
name: 'apply terraform' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout ' | |
uses: actions/checkout@master | |
# --------- prep setup gcloud --- | |
# https://github.com/terraform-google-modules/terraform-google-project-factory#software | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: '3.7' # Version range or exact version of a Python version to use, using SemVer's version range syntax | |
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master | |
- run: gcloud info | |
# --------- Stage 0 ------------- | |
- name: 'init 0-bootstrap' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: 0-bootstrap | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'apply 0-bootstrap' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'apply' | |
tf_actions_working_dir: 0-bootstrap | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# --------- Stage 1 ------------- | |
- name: 'init 1-org' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: 1-org | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'apply 1-org' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'apply' | |
tf_actions_working_dir: 1-org | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# --------- Stage 2 ------------- | |
- name: 'init 2-networks' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: 2-networks | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'apply 2-networks' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'apply' | |
tf_actions_working_dir: 2-networks | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# --------- Stage 3 ------------- | |
- name: 'init 3-projects' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: 3-projects | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'apply 3-projects' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'apply' | |
tf_actions_working_dir: 3-projects | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Bootstrap Terraform' | |
on: | |
- pull_request | |
env: | |
tf_version: 'latest' | |
tf_working_dir: '0-bootstrap' | |
GOOGLE_CREDENTIALS: ${{secrets.GOOGLE_CREDENTIALS}} | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@master | |
- name: 'Terraform Format' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'fmt' | |
tf_actions_working_dir: ${{ env.tf_working_dir }} | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Terraform Init' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'init' | |
tf_actions_working_dir: ${{ env.tf_working_dir }} | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Terraform Validate' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'validate' | |
tf_actions_working_dir: ${{ env.tf_working_dir }} | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Terraform Plan' | |
uses: hashicorp/terraform-github-actions@master | |
with: | |
tf_actions_version: ${{ env.tf_version }} | |
tf_actions_subcommand: 'plan' | |
tf_actions_working_dir: ${{ env.tf_working_dir }} | |
tf_actions_comment: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment