Skip to content

Instantly share code, notes, and snippets.

@joshuaNjordan85
Last active March 18, 2020 17:35
Show Gist options
  • Save joshuaNjordan85/4b40ad5fa6ec434eabbe3c0204d50af6 to your computer and use it in GitHub Desktop.
Save joshuaNjordan85/4b40ad5fa6ec434eabbe3c0204d50af6 to your computer and use it in GitHub Desktop.
name: 'Deploy Functions'
on:
push:
branches:
- "production"
paths:
- "infrastructure/*.tf"
pull_request:
branches:
- "master"
paths:
- "infrastructure/*.tf"
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.API_TOKEN }}
- name: 'Get Submodules'
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: 'Build OACBOT Archive'
run: |
chmod +x ./scripts/buildArchive.sh
./scripts/buildArchive.sh
- name: 'Build TFE Config'
run: |
cat << EOF > ./infrastructure/backend.tf
terraform {
backend "remote" {
hostname = "app.terraform.io"
organization = "south_self_service"
workspaces {
name = "oac-bot-$workspace"
}
}
}
EOF
env:
workspace: ${{ (github.ref == 'production' && 'production') || 'dev' }}
- name: 'Terraform Format'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 'latest'
tf_actions_subcommand: 'fmt'
tf_actions_working_dir: './infrastructure'
tf_cli_credentials_token: ${{ secrets.TERRAFORM_RC }}
tf_actions_comment: false
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 'latest'
tf_actions_subcommand: 'init'
tf_actions_working_dir: './infrastructure'
tf_actions_comment: false
args: '-backend-config="token=${{ secrets.TERRAFORM_RC }}" -backend-config="./backend.tf'
- name: 'Terraform Validate'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 'latest'
tf_actions_subcommand: 'validate'
tf_actions_working_dir: './infrastructure'
tf_cli_credentials_token: ${{ secrets.TERRAFORM_RC }}
tf_actions_comment: false
- name: 'Terraform Apply'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 'latest'
tf_actions_subcommand: 'apply'
tf_actions_working_dir: './infrastructure'
tf_cli_credentials_token: ${{ secrets.TERRAFORM_RC }}
tf_actions_comment: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment